Struct cipher_crypt::columnar_transposition::ColumnarTransposition [] [src]

pub struct ColumnarTransposition { /* fields omitted */ }

A ColumnarTransposition cipher.

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

Trait Implementations

impl Cipher for ColumnarTransposition
[src]

[src]

Initialize a Columnar Transposition cipher given a specific key.

Will return Err if one of the following conditions is detected:

  • The key length is 0.
  • The key contains non-alphanumeric symbols.
  • The key contains duplicate characters.

[src]

Encrypt a message with a Columnar Transposition cipher.

Whilst all characters (including utf8) can be encrypted during the transposition process, it is important to note that the space character is also treated as padding. As such, whitespace characters at the end of a message are not preserved during the decryption process.

Examples

Basic usage:

use cipher_crypt::{Cipher, ColumnarTransposition};

let ct = ColumnarTransposition::new(String::from("zebras")).unwrap();
assert_eq!("res pce!uemeers -ta Ss g", ct.encrypt("Super-secret message!").unwrap());

[src]

Decrypt a ciphertext with a Columnar Transposition cipher.

Examples

Basic usage:

use cipher_crypt::{Cipher, ColumnarTransposition};

let ct = ColumnarTransposition::new(String::from("zebras")).unwrap();
assert_eq!("Super-secret message!", ct.decrypt("res pce!uemeers -ta Ss g").unwrap());