Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
44
Task/Vigen-re-cipher/PL-I/vigen-re-cipher.pli
Normal file
44
Task/Vigen-re-cipher/PL-I/vigen-re-cipher.pli
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
cypher: procedure options (main); /* 21 September 2012 */
|
||||
declare t(26) character (26);
|
||||
declare (i, j, k, L) fixed binary;
|
||||
declare (original, encoded, coder) character (1000) varying initial ('');
|
||||
declare cypher character (30) varying;
|
||||
declare (co, ct, cc) character (1);
|
||||
|
||||
/* Set up cypher table. */
|
||||
t(1) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
do i = 2 to 26;
|
||||
t(i) = substr(t(i-1), 2, 25) || substr(t(i-1), 1, 1);
|
||||
end;
|
||||
|
||||
cypher = 'VIGILANCE';
|
||||
original = 'Meet me on Tuesday evening at seven.';
|
||||
put edit ('Message=', original) (a);
|
||||
original = uppercase(original);
|
||||
|
||||
/* Create the cypher text, same length as original, or longer. */
|
||||
coder = repeat(cypher, length(original)/length(cypher));
|
||||
|
||||
/* Encode the original message, character by character. */
|
||||
/* Non-alphabetic characters are ignored. */
|
||||
L = 0;
|
||||
do i = 1 to length(original);
|
||||
co = substr(original, i, 1);
|
||||
j = index(t(1), co);
|
||||
if j = 0 then iterate; /* Ignore non-alphabetic character */
|
||||
L = L + 1;
|
||||
ct = substr(coder, L, 1);
|
||||
k = index(t(1), ct);
|
||||
encoded = encoded || substr(t(j), k, 1);
|
||||
end;
|
||||
put skip data (encoded);
|
||||
|
||||
/* DECODING. */
|
||||
put skip list ('Decoded=');
|
||||
do i = 1 to length(encoded);
|
||||
cc = substr(coder, i, 1);
|
||||
j = index(t(1), cc);
|
||||
k = index(t(j), substr(encoded, i, 1));
|
||||
put edit (substr(t(1), k, 1) ) (a(1));
|
||||
end;
|
||||
end cypher;
|
||||
Loading…
Add table
Add a link
Reference in a new issue