SCAR Code:
function encodeall(WhatToEncode:string):string;
var
PlainText,CipherText:array of string;
iter,i:integer;
theboolean:boolean;
begin
PlainText:=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0']
CipherText:=['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a','0','9','8','7','6','5','4','3','2','1']
for i:=1 to Length(WhatToEncode) do
begin
iter:=0;
theboolean:=false;
repeat
if WhatToEncode[i]=PlainText[iter] then
begin
theboolean:=true;
result:=result+CipherText[iter]
end;
iter:=iter+1;
until ((theboolean) or (iter=getarraylength(plaintext)));
end;
end;
that should do it
SCAR Code:
function Cipher(WhatToEncode,EncodeOrDecode:string):string;
var
PlainText,CipherText:array of string;
iter,i:integer;
theboolean:boolean;
begin
case lowecase(EncodeOrDecode) of
'encode': begin
CipherText:=[' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0']
PlainText:=['z','y','x','w','v','u','t','s','r',' ','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a','0','9','8','7','6','5','4','3','2','1']
end;
'decode': begin
PlainText:=[' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0']
CipherText:=['z','y','x','w','v','u','t','s','r',' ','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a','0','9','8','7','6','5','4','3','2','1']
end;
end;
for i:=1 to Length(WhatToEncode) do
begin
iter:=0;
theboolean:=false;
repeat
if WhatToEncode[i]=PlainText[iter] then
begin
theboolean:=true;
result:=result+CipherText[iter]
end;
iter:=iter+1;
until ((theboolean) or (iter=getarraylength(plaintext)));
end;
end;
begin
writeln(Cipher('fsrgirgizigvxhvfinvggztv','Decode'));
end.