Struct cipher_crypt::playfair::Playfair[][src]

pub struct Playfair { /* fields omitted */ }

A Playfair cipher.

This struct is created by the new() method. See its documentation for more.

Trait Implementations

impl Cipher for Playfair
[src]

Initialize a Playfair cipher.

Warning

  • The 5x5 key table requires any 'J' characters in the key to be substituted with 'I' characters (I = J).

Encrypt a message with the Playfair cipher.

Examples

Basic Usage:

use cipher_crypt::{Cipher, Playfair};

let c = Playfair::new("playfair example".to_string()).unwrap();
assert_eq!(
    c.encrypt("Hide the gold in the tree stump").unwrap(),
    "BMODZBXDNABEKUDMUIXMMOUVIF"
);

Warning

  • The 5x5 key table requires any 'J' characters in the message to be substituted with 'I' characters (i.e. I = J).
  • The resulting ciphertext will be fully uppercase with no whitespace.

Errors

  • Messages must contain alphabetic characters only.

Decrypt a message with the Playfair cipher.

Examples

Basic Usage:

use cipher_crypt::{Cipher, Playfair};

let c = Playfair::new("playfair example".to_string()).unwrap();
assert_eq!(
    c.decrypt("BMODZBXDNABEKUDMUIXMMOUVIF").unwrap(),
    "HIDETHEGOLDINTHETREXESTUMP"
);

Warning

  • The 5x5 key table requires any 'J' characters in the message to be substituted with 'I' characters (i.e. I = J).
  • The resulting plaintext will be fully uppercase with no whitespace.
  • The resulting plaintext may contain added 'X' pad characters.

Errors

  • Messages must contain only alphabetic characters.

Auto Trait Implementations

impl Send for Playfair

impl Sync for Playfair