Learn R Programming

cryptography (version 1.0.0)

playfair: Playfair Cipher

Description

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.

Usage

playfair(message, key, encrypt = TRUE)

Value

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

Arguments

message

a character vector to be encrypted or decrypted

key

a character vector to be used as the encryption key

encrypt

(Default: TRUE) TRUE will encrypt the message, while FALSE will decrypt the message.

Examples

Run this code
playfair("SUPERSECRETMESSAGE", "safety", encrypt = TRUE)
playfair("YSQFNTFDQTGRTAAFDT", "safety", encrypt = FALSE)
playfair("$%^Att&(a09Ck___He86re", "safety", encrypt = TRUE)
playfair("FSSFKPLSQT", "safety", encrypt = FALSE)

Run the code above in your browser using DataLab