22 lines
929 B
Plaintext
22 lines
929 B
Plaintext
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
|
|
]
|