Title: | Encrypts and Decrypts Text Ciphers |
---|---|
Description: | Playfair, Four-Square, Scytale, Columnar Transposition and Autokey methods. Further explanation on methods of classical cryptography can be found at Wikipedia; (<https://en.wikipedia.org/wiki/Classical_cipher>). |
Authors: | Piaras Fahey [aut, cre, cph] |
Maintainer: | Piaras Fahey <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2025-02-14 04:26:47 UTC |
Source: | https://github.com/piarasfahey/cryptography |
This can be used to encrypt or decrypt an Autokey cipher. The Autokey Cipher is derived from the Vigenere Cipher, in which the key and plaintext are bound to generate a new encryption key for the Vigenere method. This Vigenere method uses only letters and numbers, as such any other characters used as inputs are not used in the cipher.
autokey(message, key, encrypt = TRUE)
autokey(message, key, encrypt = TRUE)
message |
A character vector of plaintext to be encrypted or ciphertext to be decrypted |
key |
A character vector to be used as the encryption key |
encrypt |
(Default: |
A character vector of either plaintext that has been encrypted or ciphertext that has been decrypted.
autokey("VerySecretMessage", "Hack", encrypt = TRUE) autokey("c4JYn8JfwNoLMbmAM", "Hack", encrypt = FALSE) autokey("Very $%^&SecretMes(*sagĀ£$%e", "Hack", encrypt = TRUE)
autokey("VerySecretMessage", "Hack", encrypt = TRUE) autokey("c4JYn8JfwNoLMbmAM", "Hack", encrypt = FALSE) autokey("Very $%^&SecretMes(*sagĀ£$%e", "Hack", encrypt = TRUE)
This can be used to encrypt or decrypt a Columnar Transposition cipher. This method is a development of the Scytale cipher that rearranges the encryption matrix used in the Scytale method by the alphabetical ordering of the encryption key.
columnar_transposition(message, key, encrypt = TRUE)
columnar_transposition(message, key, encrypt = TRUE)
message |
A character vector |
key |
A character vector composed only of a-zA-Z letters used as the encryption key |
encrypt |
(Default: |
A character vector of either plaintext that has been encrypted or ciphertext that has been decrypted using the columnar transposition cryptographic method.
columnar_transposition("Hidden message", "hack", encrypt = TRUE) columnar_transposition("insed sHeegdma", "hack", encrypt = FALSE)
columnar_transposition("Hidden message", "hack", encrypt = TRUE) columnar_transposition("insed sHeegdma", "hack", encrypt = FALSE)
This can be used to encrypt or decrypt a Four-Square cipher. The Four-Square cipher is a polygraphic substitution cipher that maps digrams of text to two encryption matrices through their position in a square alphabet matrix.
four_square(message, key1, key2, encrypt = TRUE)
four_square(message, key1, key2, encrypt = TRUE)
message |
a character vector used as the plaintext to be encrypted or the ciphertext to be decrypted |
key1 |
a character vector used as the encryption key for the first encryption matrix |
key2 |
a character vector used as the encryption key for the second encryption matrix |
encrypt |
(Default: |
A character vector of either plaintext that has been encrypted or ciphertext that has been decrypted.
four_square("THEPRISONERSHAVEESCAPED", "HACK", "SAFE", encrypt = TRUE) four_square("SHBOTDTMPFSQDFZSCUHFPBCY", "HACK", "SAFE", encrypt = FALSE)
four_square("THEPRISONERSHAVEESCAPED", "HACK", "SAFE", encrypt = TRUE) four_square("SHBOTDTMPFSQDFZSCUHFPBCY", "HACK", "SAFE", encrypt = FALSE)
This can be used to encrypt or decrypt a Playfair cipher. A Playfair cipher is a polygraphic substitution cipher that maps digrams of text to other elements of an encryption matrix which is generated by a keyword.
playfair(message, key, encrypt = TRUE)
playfair(message, key, encrypt = TRUE)
message |
a character vector to be encrypted or decrypted |
key |
a character vector to be used as the encryption key |
encrypt |
(Default: |
A character vector of either plaintext that has been encrypted or ciphertext that has been decrypted.
playfair("SUPERSECRETMESSAGE", "safety", encrypt = TRUE) playfair("YSQFNTFDQTGRTAAFDT", "safety", encrypt = FALSE) playfair("$%^Att&(a09Ck___He86re", "safety", encrypt = TRUE) playfair("FSSFKPLSQT", "safety", encrypt = FALSE)
playfair("SUPERSECRETMESSAGE", "safety", encrypt = TRUE) playfair("YSQFNTFDQTGRTAAFDT", "safety", encrypt = FALSE) playfair("$%^Att&(a09Ck___He86re", "safety", encrypt = TRUE) playfair("FSSFKPLSQT", "safety", encrypt = FALSE)
This can be used to encrypt and decrypt a Scytale cipher. A Scytale cipher is an ancient form of cryptography that wraps a message (typically written on a long thing piece of paper) around a device to create a matrix with a fixed number of columns that transposes the text.
scytale(message, col, encrypt = TRUE)
scytale(message, col, encrypt = TRUE)
message |
A character vector |
col |
A positive integer, this determines the number of columns in the encryption matrix. 1 column will have no effect |
encrypt |
(Default: |
A character vector of either plaintext that has been encrypted or ciphertext that has been decrypted.
scytale("very super secret message!", col = 4, encrypt = TRUE) scytale("v eetseesrc s!ru rmaypseeg", col = 4, encrypt = FALSE)
scytale("very super secret message!", col = 4, encrypt = TRUE) scytale("v eetseesrc s!ru rmaypseeg", col = 4, encrypt = FALSE)