Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,57 +1,57 @@
|
|||
module Caesar;
|
||||
const
|
||||
size = 25;
|
||||
size = 25;
|
||||
|
||||
type
|
||||
Operation = (code,decode);
|
||||
Operation = (code,decode);
|
||||
|
||||
procedure C_D(s:string;k:integer;op: Operation): string;
|
||||
var
|
||||
i,key: integer;
|
||||
resp: string;
|
||||
n,c: char;
|
||||
i,key: integer;
|
||||
resp: string;
|
||||
n,c: char;
|
||||
begin
|
||||
resp := "";
|
||||
if op = Operation.decode then key := k else key := (26 - k) end;
|
||||
for i := 0 to len(s) - 1 do
|
||||
c := cap(s[i]);
|
||||
if (c >= 'A') & (c <= 'Z') then
|
||||
resp := resp +
|
||||
string(char(integer('A') + ((integer(c) - integer('A') + key )) mod 26));
|
||||
else
|
||||
resp := resp + string(c)
|
||||
end;
|
||||
end;
|
||||
return resp
|
||||
resp := "";
|
||||
if op = Operation.decode then key := k else key := (26 - k) end;
|
||||
for i := 0 to len(s) - 1 do
|
||||
c := cap(s[i]);
|
||||
if (c >= 'A') & (c <= 'Z') then
|
||||
resp := resp +
|
||||
string(char(integer('A') + ((integer(c) - integer('A') + key )) mod 26));
|
||||
else
|
||||
resp := resp + string(c)
|
||||
end;
|
||||
end;
|
||||
return resp
|
||||
end C_D;
|
||||
|
||||
procedure {public} Cipher(s:string;k:integer):string;
|
||||
var
|
||||
i: integer;
|
||||
resp: string;
|
||||
n,c: char;
|
||||
i: integer;
|
||||
resp: string;
|
||||
n,c: char;
|
||||
begin
|
||||
return C_D(s,k,Operation.code)
|
||||
return C_D(s,k,Operation.code)
|
||||
end Cipher;
|
||||
|
||||
procedure {public} Decipher(s:string;k:integer):string;
|
||||
var
|
||||
i: integer;
|
||||
resp: string;
|
||||
n,c: char;
|
||||
i: integer;
|
||||
resp: string;
|
||||
n,c: char;
|
||||
begin
|
||||
return C_D(s,k,Operation.decode)
|
||||
return C_D(s,k,Operation.decode)
|
||||
end Decipher;
|
||||
|
||||
var
|
||||
txt,cipher,decipher: string;
|
||||
txt,cipher,decipher: string;
|
||||
|
||||
begin
|
||||
txt := "HI";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2);
|
||||
writeln(txt," -c-> ",cipher," -d-> ",decipher);
|
||||
txt := "ZA";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2);
|
||||
writeln(txt," -c-> ",cipher," -d-> ",decipher);
|
||||
txt := "The five boxing wizards jump quickly";
|
||||
cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2);
|
||||
writeln(txt," -c-> ",cipher," -d-> ",decipher)
|
||||
txt := "HI";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2);
|
||||
writeln(txt," -c-> ",cipher," -d-> ",decipher);
|
||||
txt := "ZA";cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2);
|
||||
writeln(txt," -c-> ",cipher," -d-> ",decipher);
|
||||
txt := "The five boxing wizards jump quickly";
|
||||
cipher := Caesar.Cipher(txt,2);decipher := Caesar.Decipher(cipher,2);
|
||||
writeln(txt," -c-> ",cipher," -d-> ",decipher)
|
||||
end Caesar.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue