caesar: Encrypt and decrypt text using the Caesar cipher.

Description Usage Arguments Value Examples

View source: R/caesar.R

Description

Encrypt and decrypt text using the Caesar cipher.

Usage

1
caesar(text, shift = 3, decrypt = FALSE)

Arguments

text

String to be ciphered or deciphered.

shift

A single whole number for how far to move the characters in the direction (positive or negative) you choose. If not a whole number, it will be rounded to nearest whole number.

decrypt

If TRUE, (not default) deciphers the coded text.

Value

String of the ciphered/deciphered text

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Please see this for more info.
# https://en.wikipedia.org/wiki/Caesar_cipher

caesar("Experience is the teacher of all things.")
caesar("HAshulhqfhclvcwkhcwhdfkhucricdoocwklqjva", decrypt = TRUE)

caesar("Veni, vidi, vici.",  shift = 40)
caesar(",S1WKN9WRWKN9WQWL", shift = 40, decrypt = TRUE)

caesar("No one is so brave that he is not disturbed by something unexpected.", shift = -12)
caesar("Bc[cb:[,g[gc[{f]j:[h>]h[>:[,g[bch[;,ghif{:;[{m[gca:h>,b<[ib:ld:}h:;`",
       shift = -12, decrypt = TRUE)

Example output

[1] "HAshulhqfhclvcwkhcwhdfkhucricdoocwklqjva"
[1] "Experience is the teacher of all things."
[1] ",S1WKN9WRWKN9WQWL"
[1] "Veni, vidi, vici."
[1] "Bc[cb:[,g[gc[{f]j:[h>]h[>:[,g[bch[;,ghif{:;[{m[gca:h>,b<[ib:ld:}h:;`"
[1] "No one is so brave that he is not disturbed by something unexpected."

caesar documentation built on Sept. 3, 2020, 5:06 p.m.