Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Vigen-re-cipher/XPL0/vigen-re-cipher.xpl0
Normal file
21
Task/Vigen-re-cipher/XPL0/vigen-re-cipher.xpl0
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
code ChIn=7, ChOut=8;
|
||||
int Neg, C, Len, I, Key;
|
||||
char KeyWord(80);
|
||||
[Neg:= false; \skip to KEYWORD
|
||||
repeat C:= ChIn(8); if C=^- then Neg:= true; until C>=^A & C<=^Z;
|
||||
Len:= 0; \read in KEYWORD
|
||||
repeat KeyWord(Len):= C-^A; Len:= Len+1; C:= ChIn(8); until C<^A ! C>^Z;
|
||||
I:= 0; \initialize cycling index
|
||||
repeat C:= ChIn(1);
|
||||
if C>=^a & C<=^z then C:= C-$20; \capitalize
|
||||
if C>=^A & C<=^Z then \discard non-alphas
|
||||
[Key:= KeyWord(I); I:= I+1; if I>=Len then I:= 0;
|
||||
if Neg then Key:= -Key; \decrypting?
|
||||
C:= C+Key;
|
||||
if C>^Z then C:= C-26
|
||||
else if C<^A then C:= C+26;
|
||||
ChOut(0, C);
|
||||
];
|
||||
until C=$1A; \EOF
|
||||
ChOut(0, $1A); \encrypted file must end with EOF otherwise the decode will hang
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue