caesar {cipheR}R Documentation

Encrypt or decrypt a Caesar Cipher

Description

This can be used to create (encrypt) and solve (decrypt) a Caesar cipher. The function does not differentiate between the two.

The Caesar Cipher Wikipedia entry provides more information on the methods used: https://en.wikipedia.org/wiki/Caesar_cipher

Usage

caesar(x, n = 1, preserve_spaces = TRUE, dict = NULL, preset = NULL)

Arguments

x

A vector to be shifted

n

(Default: 1) The number of places to shift by. This can be either positive or negative. Zero returns x as it was given to the function.

preserve_spaces

(Default: TRUE) A boolean describing if spaces should be preserved. This is helpful when working with sentences.

dict

The dictionary used for shifting. This defaults to NULL in which case a dictionary is built from the sorted unique values of x.

preset

A pre-made dictionary using ASCII codes from https://www.ascii-code.com/. Note that delete is excluded as a character.

  • NULL (the default)

  • "alphanumeric": ASCII characters 48:57, 65:90, and 97:122. Numbers 0-9 and both uppercase and lowercase letters from the English alphabet.

  • "keyboard": ASCII characters 32:126. The characters you'll find on a US English keyboard.

  • "letters": ASCII characters 65:90 and 97:122. Both uppercase and lowercase letters from the English alphabet.

  • "lowercase": ASCII characters 97:122. Lowercase letters from the English alphabet.

  • "uppercase": ASCII characters 65:90. Uppercase letters from the English alphabet.

Value

A character vector of length one that has been shifted.


[Package cipheR version 1.0.0 Index]