SRL Archive - Non-RuneScape Scripts

Shift13


Kyle Undefined

2012-04-12 00:31:14

I was bored tonight, so I made this. I saw something like this awhile ago and thought it was neat. It just shifts the text 13 chars over to "encrypt" it, but it's not really encryption. Try it out! :)

Thanks to m34tcode for helping me work through a few ideas on Skype.


program Shift13;

const
_text = 'THIS is a TesT';

function getCharArray(whatString : string) : TStringArray;
var
tempArray : TStringArray;
tempString : string;
count, i : Integer;
begin
tempString := whatString;
repeat
Delete(tempString, 1, 1);
Inc(count);
until(tempString = '');

Setlength(tempArray, count);

for i := 0 to (count - 1) do
tempArray[i] := Copy(whatString, i + 1, 1);

Result := tempArray;
end;

function toChar(s : string) : Char;
begin
Result := s[1];
end;

function _shift(s : string) : string;
var
tmpStrArr : TStringArray;
res : string;
i : Integer;
c : LongInt;
begin
tmpStrArr := getCharArray(s);
for i := 0 to High(tmpStrArr) do
begin
c := Ord(toChar(tmpStrArr[i]));
if(InRange(c, 97, 122))then
begin
IncEx(c, 13);
if(c > 122)then
DecEx(c, 26);
end else
if(InRange(c, 65, 90))then
begin
IncEx(c, 13);
if(c > 90)then
DecEx(c, 26);
end;
res := res + Chr(c);
end;

Result := res;
end;

function _reShift(s : string) : string;
begin
Result := _shift(s);
end;

procedure _main();
var
rText : string;
begin
rText := _shift(_text);
WriteLn('Original text := ' + _text);
WriteLn('Shifted text := ' + rText);
WriteLn('Re-shifted text := ' + _reShift(rText));
end;

begin
ClearDebug();
_main();
end.

Justin

2012-04-12 00:32:39

It works! Thanks Kyle!

Flight

2012-04-12 00:34:30

Lol looks like fun, nice work.

Neznam

2012-04-12 00:41:54

Too much free time on your hands!!! Solve world hunger… peace in the middle east… the crazyness in Syria… nah lets not go there.

Haha.
Great work :]

illuminatiswag

2012-04-12 00:46:39

hey this look neat people can have fun with this

Kyle Undefined

2012-04-12 07:13:46

Haha Justin :(

Thanks! It was just something fun :)

Jordan155

2012-04-12 07:15:01

From: [J]ustin
It works! Thanks Kyle!


Bahahaha

Imanoobbot

2012-04-12 07:21:36

Looks funny!
Will test this after eating. :D

Toby1

2012-04-12 18:04:28

Wow awesome. :D

Echo_

2012-04-13 10:45:14

The technical term for this is the Caesar Cipher if anybody is interested :p

Kyle Undefined

2012-04-13 10:58:53

Oh nice, didn't know that's what it was called. I might just expand this now ;)

Sir Ducksworthy

2012-04-13 18:52:14

Wow I think this is beautiful Kyle.
Would be fun using this to make Encrypted Procedures

Daniel

2012-04-25 10:08:17

Made this a loong time ago :p Can me made muuch simpler, you noob! :p


program CaesarCipher;

const
Str = 'Kyle is a noob!!!';
Difference = -1;

function WrapRange(const Val, A, B: Word): Word;
var
Diff: Word;
begin
Result := Val;
Diff := Trunc(Abs(B - A));

if(Val < A) then
Result := Val + Diff + 1;
if(Val > B) then
Result := Val - Diff - 1;
end;

var
I: Integer;
Res: String;
tempOrd: Byte;

begin
for I := 1 to Length(Str) do
begin
tempOrd := Ord(Str[I]);

case (True) of
InRange(tempOrd, 65, 90) : Res := Res + Chr(WrapRange(tempOrd + Difference, 65, 90));
InRange(tempOrd, 97, 122) : Res := Res + Chr(WrapRange(tempOrd + Difference, 97, 122));
else
Res := Res + Str[I];
end;
end;

Writeln(Res);
end.

Justin

2012-04-28 11:54:28

From: Daniel
Made this a loong time ago :p Can me made muuch simpler, you noob! :p


program CaesarCipher;

const
Str = 'Kyle is a noob!!!';
Difference = -1;

function WrapRange(const Val, A, B: Word): Word;
var
Diff: Word;
begin
Result := Val;
Diff := Trunc(Abs(B - A));

if(Val < A) then
Result := Val + Diff + 1;
if(Val > B) then
Result := Val - Diff - 1;
end;

var
I: Integer;
Res: String;
tempOrd: Byte;

begin
for I := 1 to Length(Str) do
begin
tempOrd := Ord(Str[I]);

case (True) of
InRange(tempOrd, 65, 90) : Res := Res + Chr(WrapRange(tempOrd + Difference, 65, 90));
InRange(tempOrd, 97, 122) : Res := Res + Chr(WrapRange(tempOrd + Difference, 97, 122));
else
Res := Res + Str[I];
end;
end;

Writeln(Res);
end.



See Kyle, I'm not the only one calling you a noob!