[−][src]Trait ciphers::Cipher
Defines the implementation for cipher functionality.
Required methods
fn encipher(&self, ptext: &str) -> CipherResult
Should take plaintext as a string reference, and return the enciphered ciphertext as
a CipherResult
.
fn decipher(&self, ctext: &str) -> CipherResult
Should take the ciphertext as a string reference, and return the deciphered plaintext
as a CipherResult
.
Implementors
impl Cipher for ADFGVX
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the ADFGVX cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, ADFGVX}; let adfgvx = ADFGVX::new("PH0QG64MEA1YL2NOFDXKR3CVS5ZW7BJ9UTI8", "GERMAN"); let ctext = adfgvx.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "FFDVDFADFXFGFGAVFAFFDXDXFFDVDFFDGGAGVGVXFAGGDGADFADVFXGX");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the ADFGVX cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, ADFGVX}; let adfgvx = ADFGVX::new("PH0QG64MEA1YL2NOFDXKR3CVS5ZW7BJ9UTI8", "GERMAN"); let ptext = adfgvx.decipher("FFDVDFADFXFGFGAVFAFFDXDXFFDVDFFDGGAGVGVXFAGGDGADFADVFXGX"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for ADFGX
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the ADFGX cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, ADFGX}; let adfgx = ADFGX::new("PHQGMEAYNOFDXKRCVSZWBUTIL", "GERMAN"); let ctext = adfgx.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "FFDGDDADXDAFAFXAAFAFDXDXXFDGDAGDDXXFAFADAFDXDDXDDADGXXGX");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the ADFGX cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, ADFGX}; let adfgx = ADFGX::new("PHQGMEAYNOFDXKRCVSZWBUTIL", "GERMAN"); let ptext = adfgx.decipher("FFDGDDADXDAFAFXAAFAFDXDXXFDGDAGDDXXFAFADAFDXDDXDDADGXXGX"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Affine
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Affine cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Affine}; let affine = Affine::new(7, 11); let ctext = affine.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "GNUNYGOINNLHOJLKKFUOINZLHOKN");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Affine cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, Affine}; let affine = Affine::new(7, 11); let ptext = affine.decipher("GNUNYGOINNLHOJLKKFUOINZLHOKN"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Atbash
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Atbash cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Atbash}; let atbash = Atbash::new(); let ctext = atbash.encipher("ATTACKATDAWN"); assert_eq!(ctext.unwrap(), "ZGGZXPZGWZDM");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Atbash cipher
and returns the plaintext as a CipherResult
.
Note that the Atbash cipher is reciprocal.
Example
use ciphers::{Cipher, Atbash}; let atbash = Atbash::new(); let ptext = atbash.decipher("ZGGZXPZGWZDM"); assert_eq!(ptext.unwrap(), "ATTACKATDAWN");
impl Cipher for Autokey
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Autokey cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Autokey}; let autokey = Autokey::new("FORTIFICATION"); let ctext = autokey.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "ISWXVIBJEXIGGZEQPBIMOIGAKMHE");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Autokey cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, Autokey}; let autokey = Autokey::new("FORTIFICATION"); let ptext = autokey.decipher("ISWXVIBJEXIGGZEQPBIMOIGAKMHE"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Beaufort
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Beaufort cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Beaufort}; let beaufort = Beaufort::new("FORTIFICATION"); let ctext = beaufort.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "CKMPVCPVWPIWUJOGIUAPVWRIWUUK");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Beaufort cipher
and returns the plaintext as a CipherResult
.
Note that the Beaufort cipher is reciprocal.
Example
use ciphers::{Cipher, Beaufort}; let beaufort = Beaufort::new("FORTIFICATION"); let ptext = beaufort.decipher("CKMPVCPVWPIWUJOGIUAPVWRIWUUK"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Caesar
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Caesar cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Caesar}; let caesar = Caesar::new(1); let ctext = caesar.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "EFGFOEUIFFBTUXBMMPGUIFDBTUMF");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Caesar cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, Caesar}; let caesar = Caesar::new(1); let ptext = caesar.decipher("EFGFOEUIFFBTUXBMMPGUIFDBTUMF"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for ColumnarTransposition
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Columnar
Transposition cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, ColumnarTransposition}; let ct = ColumnarTransposition::new("GERMAN"); let ctext = ct.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "NALCEHWTTDTTFSEELEEDSOAFEAHL")
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Columnar
Transposition cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, ColumnarTransposition}; let ct = ColumnarTransposition::new("GERMAN"); let ptext = ct.decipher("NALCEHWTTDTTFSEELEEDSOAFEAHL"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for FourSquare
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Four-Square
cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, FourSquare}; let four_square = FourSquare::new( "ZGPTFOIHMUWDRCNYKEQAXVSBL", "MFNBDCRHSAXYOGVITUEWLQZKP", "ABCDEFGHIKLMNOPQRSTUVWXYZ", 'X', ); let ctext = four_square.encipher("ATTACKATDAWN"); assert_eq!(ctext.unwrap(), "TIYBFHTIZBSY");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Four-Square
cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, FourSquare}; let four_square = FourSquare::new( "ZGPTFOIHMUWDRCNYKEQAXVSBL", "MFNBDCRHSAXYOGVITUEWLQZKP", "ABCDEFGHIKLMNOPQRSTUVWXYZ", 'X', ); let ptext = four_square.decipher("TIYBFHTIZBSY"); assert_eq!(ptext.unwrap(), "ATTACKATDAWN");
impl Cipher for Playfair
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Playfair cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Playfair}; let playfair = Playfair::new("ZGPTFOIHMUWDRCNYKEQAXVSBL", 'X'); let ctext = playfair.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "RKPAWRPMYSELZCLFXUZFRSNQBPSA");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Playfair cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, Playfair}; let playfair = Playfair::new("ZGPTFOIHMUWDRCNYKEQAXVSBL", 'X'); let ptext = playfair.decipher("RKPAWRPMYSELZCLFXUZFRSNQBPSA"); assert_eq!(ptext.unwrap(), "DEFENDTHEXASTWALLOFTHECASTLE");
impl Cipher for PolybiusSquare
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Polybius Square
cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, PolybiusSquare}; let ps = PolybiusSquare::new("PHQGIUMEAYLNOFDXKRCVSTZWB", "ABCDE"); let ctext = ps.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "CEBCCDBCCBCEEBABBCBCBDEAEBEDBDCACACCCDEBABBCDDBDEAEBCABC");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Polybius Square
cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, PolybiusSquare}; let ps = PolybiusSquare::new("PHQGIUMEAYLNOFDXKRCVSTZWB", "ABCDE"); let ptext = ps.decipher("CEBCCDBCCBCEEBABBCBCBDEAEBEDBDCACACCCDEBABBCDDBDEAEBCABC"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Porta
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Porta cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Porta}; let porta = Porta::new("FORTIFICATION"); let ctext = porta.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "SYNNJSCVRNRLAHUTUKUCVRYRLANY");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Porta cipher
and returns the plaintext as a CipherResult
.
Note that the Porta cipher is reciprocal.
Example
use ciphers::{Cipher, Porta}; let porta = Porta::new("FORTIFICATION"); let ptext = porta.decipher("SYNNJSCVRNRLAHUTUKUCVRYRLANY"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for RailFence
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Rail-fence
cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, RailFence}; let rail_fence = RailFence::new(4); let ctext = rail_fence.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "DTTFSEDHSWOTATFNEAALHCLEELEE");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Rail-fence
cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, RailFence}; let rail_fence = RailFence::new(4); let ptext = rail_fence.decipher("DTTFSEDHSWOTATFNEAALHCLEELEE"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for RunningKey
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Running Key
cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, RunningKey}; let running_key = RunningKey::new("HOWDOESTHEDUCKKNOWTHATSAIDVICTOR"); let ctext = running_key.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "KSBHBHLALIDMVGKYZKYAHXUAAWGM");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Running Key
cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, RunningKey}; let running_key = RunningKey::new("HOWDOESTHEDUCKKNOWTHATSAIDVICTOR"); let ptext = running_key.decipher("KSBHBHLALIDMVGKYZKYAHXUAAWGM"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Substitution
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Simple
Substitution cipher and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Substitution}; let substitution = Substitution::new("PHQGIUMEAYLNOFDXJKRCVSTZWB"); let ctext = substitution.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "GIUIFGCEIIPRCTPNNDUCEIQPRCNI");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Simple
Substitution cipher and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, Substitution}; let substitution = Substitution::new("PHQGIUMEAYLNOFDXJKRCVSTZWB"); let ptext = substitution.decipher("GIUIFGCEIIPRCTPNNDUCEIQPRCNI"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");
impl Cipher for Vigenere
[src]
fn encipher(&self, ptext: &str) -> CipherResult
[src]
Enciphers the given plaintext (a str reference) using the Vignere cipher
and returns the ciphertext as a CipherResult
.
Example
use ciphers::{Cipher, Vigenere}; let vigenere = Vigenere::new("FORTIFICATION"); let ctext = vigenere.encipher("DEFENDTHEEASTWALLOFTHECASTLE"); assert_eq!(ctext.unwrap(), "ISWXVIBJEXIGGBOCEWKBJEVIGGQS");
fn decipher(&self, ctext: &str) -> CipherResult
[src]
Deciphers the given ciphertext (a str reference) using the Vigenere cipher
and returns the plaintext as a CipherResult
.
Example
use ciphers::{Cipher, Vigenere}; let vigenere = Vigenere::new("FORTIFICATION"); let ptext = vigenere.decipher("ISWXVIBJEXIGGBOCEWKBJEVIGGQS"); assert_eq!(ptext.unwrap(), "DEFENDTHEEASTWALLOFTHECASTLE");