32 lines
1 KiB
Text
32 lines
1 KiB
Text
[ [] swap witheach
|
|
[ upper
|
|
dup char A char Z 1+ within
|
|
iff join else drop ] ] is onlycaps ( $ --> $ )
|
|
|
|
[ onlycaps
|
|
[] swap witheach
|
|
[ char A - join ] ] is cipherdisk ( $ --> [ )
|
|
|
|
[ [] swap witheach
|
|
[ 26 swap - join ] ] is deciphering ( [ --> [ )
|
|
|
|
[ behead tuck join swap ] is nextkey ( [ --> [ n )
|
|
|
|
[ dip nextkey + dup
|
|
char Z > if [ 26 - ] ] is encryptchar ( [ c --> [ c )
|
|
|
|
[ $ "" swap rot
|
|
onlycaps witheach
|
|
[ encryptchar
|
|
swap dip join ]
|
|
drop ] is vigenere ( $ [ --> $ )
|
|
|
|
[ cipherdisk vigenere ] is encrypt ( $ $ --> $ )
|
|
|
|
[ cipherdisk deciphering vigenere ] is decrypt ( $ $ --> $ )
|
|
|
|
$ "If you reveal your secrets to the wind, you should "
|
|
$ "not blame the wind for revealing them to the trees." join
|
|
|
|
say "Encrypted: " $ "Kahlil Gibran" encrypt dup echo$ cr
|
|
say "Decrypted: " $ "Kahlil Gibran" decrypt echo$
|