September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
12
Task/Vigen-re-cipher/Zkl/vigen-re-cipher-1.zkl
Normal file
12
Task/Vigen-re-cipher/Zkl/vigen-re-cipher-1.zkl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fcn encipher(src,key,is_encode){
|
||||
upperCase:=["A".."Z"].pump(String);
|
||||
src=src.toUpper().inCommon(upperCase); // only uppercase
|
||||
key=key.toUpper().inCommon(upperCase).pump(List,"toAsc");
|
||||
|
||||
const A="A".toAsc();
|
||||
klen:=Walker.cycle(key.len()); // 0,1,2,3,..,keyLen-1,0,1,2,3, ...
|
||||
src.pump(String,'wrap(c){ i:=klen.next(); c=c.toAsc();
|
||||
(A + ( if(is_encode) c - A + key[i] - A;
|
||||
else c - key[i] + 26 ) % 26).toChar()
|
||||
});
|
||||
}
|
||||
9
Task/Vigen-re-cipher/Zkl/vigen-re-cipher-2.zkl
Normal file
9
Task/Vigen-re-cipher/Zkl/vigen-re-cipher-2.zkl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
str := "Beware the Jabberwock, my son! The jaws that bite, "
|
||||
"the claws that catch!";
|
||||
key := "Vigenere Cipher";
|
||||
|
||||
println("Text: ", str);
|
||||
println("key: ", key);
|
||||
|
||||
cod := encipher(str, key, True); println("Code: ", cod);
|
||||
dec := encipher(cod, key, False); println("Back: ", dec);
|
||||
Loading…
Add table
Add a link
Reference in a new issue