Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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()
});
}

View 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);