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]
impl Cipher for Playfair
type Key = String
type Algorithm = Playfair
fn new(key: Self::Key) -> Result<Playfair, &'static str>
[src]
fn new(key: Self::Key) -> Result<Playfair, &'static str>
Initialize a Playfair cipher.
Warning
- The 5x5 key table requires any 'J' characters in the key to be substituted with 'I' characters (I = J).
fn encrypt(&self, message: &str) -> Result<String, &'static str>
[src]
fn encrypt(&self, message: &str) -> Result<String, &'static str>
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.
fn decrypt(&self, message: &str) -> Result<String, &'static str>
[src]
fn decrypt(&self, message: &str) -> Result<String, &'static str>
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.