pub struct Playfair { /* private fields */ }
Expand description

A Playfair cipher.

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

Trait Implementations§

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§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.