Encrypt and Decrypt text using the Caesar cipher

caesar(text, direction = "left", distance = 3, decrypt = FALSE)

Arguments

text

String to be ciphered or deciphered

direction

Move the original characters the right or to the left

distance

How far to move the characters in the direction you choose.

decrypt

If TRUE, deciphers the coded text

Value

String of the ciphered/deciphered text

Examples

# Please see this for more info. # https://en.wikipedia.org/wiki/Caesar_cipher caesar("cats are friends!")
#> fdwv@duh@iulhqgv&
#> [1] "fdwv@duh@iulhqgv&"
caesar("fdwv@duh@iulhqgv&", decrypt = TRUE)
#> cats are friends!
#> [1] "cats are friends!"
caesar("cats are friends!", direction = "right", distance = 40)
#> ki10:izm:nzqmvl0;
#> [1] "ki10:izm:nzqmvl0;"
caesar("ki10:izm:nzqmvl0;", direction = "right", distance = 40, decrypt = TRUE)
#> cats are friends!
#> [1] "cats are friends!"
caesar("cats are #1 friend!", direction = "left", distance = -12)
#> , hgy f&ypy%f:&b@z
#> [1] ", hgy f&ypy%f:&b@z"
caesar(", hgy f&ypy%f:&b@z", direction = "left", distance = -12, decrypt = TRUE)
#> cats are 1 friend!
#> [1] "cats are 1 friend!"