Vigenere: Vigenere Cypher

Description Usage Arguments Details Value Author(s) Examples

View source: R/DescTools.r

Description

Implements a Vigenere cypher, both encryption and decryption. The function handle keys and text of unequal length and discards non-alphabetic characters.

Usage

1
Vigenere(x, key = NULL, decrypt = FALSE)

Arguments

x

the text to be encrypted

key

the key to be used. If this remains to NULL the PasswordDlg will be presented and the key can be entered there.

decrypt

boolean defining if the text should be encrypted or decrypted.

Details

All characters beside charlist = c(LETTERS, letters, 0:9) will be discarded from the text and from the key.

Value

the encrypted, resp. decrypted text

Author(s)

Andri Signorell <[email protected]>
strongly based on code found at http://rosettacode.org/wiki/Vigen%C3%A8re_cipher#R (credits to the unknown soldier)

Examples

1
2
3
4
5
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

Example output

[1] "NS10cIaFNnk5PYmo0QpCjWVLCBoDOqnltOy1TXLRQ8mFOqnltOy2LXJF"
[1] "BewaretheJabberwockmysonThejawsthatbitetheclawsthatcatch"

DescTools documentation built on March 19, 2018, 9:03 a.m.