This can be used to create (encrypt) and solve (decrypt) a Running Key Vigenere Cipher. A Vigenere cipher uses a table of alphabetic Caesar shifts for one to twenty-six. The key is made to have an equal length to the text by adding the first letters of the text to the key. Each letter and corresponding key value determine the grid location to choose the obfuscated letter from.
The Running Key Cipher Wikipedia entry provides more information on the methods used: https://en.wikipedia.org/wiki/Running_key_cipher
Arguments
- x
A vector to be encoded or decoded.
- key
A character vector of length one to use as a key
- decrypt
(Default:
FALSE
) The defaultFALSE
will encrypt while usingTRUE
will decrypt a given value ofx
.- keep_punctuation
(Default:
FALSE
) The defaultFALSE
will ignore case and punctuation and return a lowercase result.TRUE
will match the input's case and punctuation.
Examples
key <- "thisismysupersecurekey"
(e1 <- running_key("abcde", key))
#> [1] "tikvm"
running_key(e1, key, decrypt = TRUE)
#> [1] "abcde"
(e2 <- running_key("cipheR is a great R package!", key))
#> [1] "vpxzmjuqsagirlvrutokkc"
running_key(e2, key, decrypt = TRUE)
#> [1] "cipherisagreatrpackage"
(e3 <- running_key("Isn't this fun?", key, keep_punctuation = TRUE))
#> [1] "Bzv'l bzuq xoc?"
running_key(e3, key, decrypt = TRUE, keep_punctuation = TRUE)
#> [1] "Isn't this fun?"