Title: | Encryption and Decryption with Text Ciphers |
---|---|
Description: | Encrypts and decrypts using basic ciphers. None of these should be used in place of real encryption using state of the art tools. The ciphers included use methods described in the ciphers's Wikipedia and cryptography hobby websites. |
Authors: | Gus Lipkin [aut, cre] |
Maintainer: | Gus Lipkin <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.0 |
Built: | 2025-02-13 05:43:31 UTC |
Source: | https://github.com/guslipkin/cipher |
This can be used to create (encrypt) and solve (decrypt) an Atbash Cipher. An Atbash Cipher swaps letters' places in the alphabet. Thus, 'a' becomes 'z', 'b' becomes 'y', and so on. The function does not differentiate between the two.
The Atbash Cipher Wikipedia entry provides more information on the methods used: https://en.wikipedia.org/wiki/Atbash
atbash(x)
atbash(x)
x |
A vector to be encoded or decoded. |
A character vector of length one that has been transformed
(e1 <- atbash("abcde")) atbash(e1) (e2 <- atbash("cipheR is a great R package!")) atbash(e2) (e3 <- atbash("Isn't this fun?")) atbash(e3)
(e1 <- atbash("abcde")) atbash(e1) (e2 <- atbash("cipheR is a great R package!")) atbash(e2) (e3 <- atbash("Isn't this fun?")) atbash(e3)
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
caesar(x, n = 1, preserve_spaces = TRUE, dict = NULL, preset = NULL)
caesar(x, n = 1, preserve_spaces = TRUE, dict = NULL, preset = NULL)
x |
A vector to be shifted |
n |
(Default: |
preserve_spaces |
(Default: |
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
|
A character vector of length one that has been shifted.
(e1 <- caesar("abcde", 1)) caesar(e1, -1) (e2 <- caesar("cipheR is a great R package!", -5)) caesar(e2, 5) (e3 <- caesar("Isn't this fun?", 2, preserve_spaces = FALSE)) caesar(e3, -2, preserve_spaces = FALSE)
(e1 <- caesar("abcde", 1)) caesar(e1, -1) (e2 <- caesar("cipheR is a great R package!", -5)) caesar(e2, 5) (e3 <- caesar("Isn't this fun?", 2, preserve_spaces = FALSE)) caesar(e3, -2, preserve_spaces = FALSE)
This can be used to create (encrypt) and solve (decrypt) a Railfence Cipher. A Railfence Cipher maps each letter to a cosine wave of the specified height where each letter resides at an integer rail height.
The Railfence Cipher Wikipedia entry provides more information on the methods used: https://en.wikipedia.org/wiki/Rail_fence_cipher
railfence(x, n = 1, decrypt = FALSE)
railfence(x, n = 1, decrypt = FALSE)
x |
A vector to be encoded or decoded. |
n |
(Default: |
decrypt |
(Default: |
A character vector of length one that has been transformed
(e1 <- railfence("abcde", 2)) railfence(e1, 2, decrypt = TRUE) (e2 <- railfence("cipheR is a great R package!", 4)) railfence(e2, 4, decrypt = TRUE) (e3 <- railfence("Isn't this fun?", 3)) railfence(e3, 3, decrypt = TRUE)
(e1 <- railfence("abcde", 2)) railfence(e1, 2, decrypt = TRUE) (e2 <- railfence("cipheR is a great R package!", 4)) railfence(e2, 4, decrypt = TRUE) (e3 <- railfence("Isn't this fun?", 3)) railfence(e3, 3, decrypt = TRUE)
This can be used to create (encrypt) and solve (decrypt) a Running Key Vigenere Cipher. A Vigenere cipher uses a table of alphabetic Caesar shifts for one to twenty-six. The key is made to have an equal length to the text by adding the first letters of the text to the key. Each letter and corresponding key value determine the grid location to choose the obfuscated letter from.
The Running Key Cipher Wikipedia entry provides more information on the methods used: https://en.wikipedia.org/wiki/Running_key_cipher
running_key(x, key, decrypt = FALSE, keep_punctuation = FALSE)
running_key(x, key, decrypt = FALSE, keep_punctuation = FALSE)
x |
A vector to be encoded or decoded. |
key |
A character vector of length one to use as a key |
decrypt |
(Default: |
keep_punctuation |
(Default: |
A character vector of length equal to x that has been transformed
key <- "thisismysupersecurekey" (e1 <- running_key("abcde", key)) running_key(e1, key, decrypt = TRUE) (e2 <- running_key("cipheR is a great R package!", key)) running_key(e2, key, decrypt = TRUE) (e3 <- running_key("Isn't this fun?", key, keep_punctuation = TRUE)) running_key(e3, key, decrypt = TRUE, keep_punctuation = TRUE)
key <- "thisismysupersecurekey" (e1 <- running_key("abcde", key)) running_key(e1, key, decrypt = TRUE) (e2 <- running_key("cipheR is a great R package!", key)) running_key(e2, key, decrypt = TRUE) (e3 <- running_key("Isn't this fun?", key, keep_punctuation = TRUE)) running_key(e3, key, decrypt = TRUE, keep_punctuation = TRUE)
This can be used to create (encrypt) and solve (decrypt) a Vigenere Cipher. A Vigenere cipher uses a table of alphabetic Caesar shifts for one to twenty-six. Each letter and corresponding key value determine the grid location to choose the obfuscated letter from.
The Vigenere Cipher Wikipedia entry provides more information on the methods used: https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
vigenere(x, key, decrypt = FALSE, keep_punctuation = FALSE)
vigenere(x, key, decrypt = FALSE, keep_punctuation = FALSE)
x |
A vector to be encoded or decoded. |
key |
A character vector of length one to use as a key |
decrypt |
(Default: |
keep_punctuation |
(Default: |
A character vector of length equal to x that has been transformed
(e1 <- vigenere("abcde", "key")) vigenere(e1, "key", decrypt = TRUE) (e2 <- vigenere("cipheR is a great R package!", "key")) vigenere(e2, "key", decrypt = TRUE) (e3 <- vigenere("Isn't this fun?", "key", keep_punctuation = TRUE)) vigenere(e3, "key", decrypt = TRUE, keep_punctuation = TRUE)
(e1 <- vigenere("abcde", "key")) vigenere(e1, "key", decrypt = TRUE) (e2 <- vigenere("cipheR is a great R package!", "key")) vigenere(e2, "key", decrypt = TRUE) (e3 <- vigenere("Isn't this fun?", "key", keep_punctuation = TRUE)) vigenere(e3, "key", decrypt = TRUE, keep_punctuation = TRUE)