Task

Implement a   Vigenère cypher,   both encryption and decryption.

The program should handle keys and text of unequal length,
and should capitalize everything and discard non-alphabetic characters. 

(If your program handles non-alphabetic characters in another way,
make a note of it.)



Related tasks

   Caesar cipher
   Rot-13
   Substitution Cipher


  [ [] 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$