Package 'caesar'

Title: Encrypts and Decrypts Strings
Description: Encrypts and decrypts strings using either the Caesar cipher or a pseudorandom number generation (using set.seed()) method.
Authors: Jacob Kaplan [aut, cre]
Maintainer: Jacob Kaplan <[email protected]>
License: MIT + file LICENSE
Version: 1.1.1
Built: 2024-10-30 04:30:46 UTC
Source: https://github.com/jacobkap/caesar

Help Index


Encrypt and decrypt text using the Caesar cipher.

Description

Encrypt and decrypt text using the Caesar cipher.

Usage

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

Arguments

text

String or vector of strings (numeric input will be coerced to 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

# 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)

Encrypt and decrypt text using pseudorandom number generation based on the seed set.

Description

Encrypt and decrypt text using pseudorandom number generation based on the seed set.

Usage

seed_cipher(text, seed = 64, decrypt = FALSE)

Arguments

text

String to be ciphered or deciphered.

seed

A single number to set the seed which will pseudorandomly rearrange the original characters

decrypt

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

Value

String of the ciphered/deciphered text

Examples

seed_cipher("Cowards die many times before their deaths")
seed_cipher("'Ced<,#G,QhG$dXoG/Q$h#G+h(C<hG/0hQ<G,hd/0#",
            decrypt = TRUE)

seed_cipher("Men willingly believe what they wish.",
             seed = 2354)
seed_cipher("q39l*D66D9;6.l%36D3d3l*<p4l4<3.l*D <h",
            seed = 2354,
            decrypt = TRUE)

seed_cipher("the valiant never taste of death but once.",
            seed = -100)
seed_cipher("*QDc3f>efk*ckD3D{c*fu*DcS'c]Df*Qcy%*cSkoDi",
            seed = -100,
            decrypt = TRUE)