four_square {cryptography}R Documentation

Four-Square Cipher

Description

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.

Usage

four_square(message, key1, key2, encrypt = TRUE)

Arguments

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: TRUE) TRUE will encrypt the message, while FALSE will decrypt the message.

Value

A character vector of either plaintext that has been encrypted or ciphertext that has been decrypted.

Examples

four_square("THEPRISONERSHAVEESCAPED", "HACK", "SAFE", encrypt = TRUE)
four_square("SHBOTDTMPFSQDFZSCUHFPBCY", "HACK", "SAFE", encrypt = FALSE)


[Package cryptography version 1.0.0 Index]