Vigenere | R Documentation |
Implements a Vigenere cypher, both encryption and decryption. The function handle keys and text of unequal length and discards non-alphabetic characters.
Vigenere(x, key = NULL, decrypt = FALSE)
x |
the text to be encrypted |
key |
the key to be used. If this remains to |
decrypt |
boolean defining if the text should be encrypted or decrypted. |
All characters beside charlist = c(LETTERS, letters, 0:9) will be discarded from the text and from the key.
the encrypted, resp. decrypted text
Andri Signorell <andri@signorell.net>
strongly based on code found at https://rosettacode.org/wiki/Vigen%C3%A8re_cipher#R (credits to the unknown soldier)
key <- "My FavoriteKey452"
(xenc <- Vigenere("Beware the Jabberwock, my son! The jaws that bite, the claws that catch!", key))
Vigenere(xenc, key, decrypt = TRUE)
# note that everything besides the characters in the list will be discarded
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.