Struct cipher_crypt::polybius::Polybius [] [src]

pub struct Polybius { /* fields omitted */ }

A Polybius square cipher.

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

Trait Implementations

impl Cipher for Polybius
[src]

Initialise a Polybius square cipher.

In this implementation each part of the key is used to initialise a 6x6 polybius square. The key tuple maps to the following (String, [char; 6], [char; 6]) = (phase, column_ids, row_ids).

Where ...

  • phrase is used to generate an alphanumeric keyed alphabet. It can contain characters a-z 0-9.
  • column_ids are unique identifiers used for each column of the polybius square. Valid characters are alphabetic only (a-z).
  • row_ids are unique identifiers used for each row of the polybius square. Valid characters can be alphabetic only (a-z).

Example

Lets say the phrase was or0an3ge the column_ids were ['A','Z','C','D','E','F'] and the row_ids were ['A','B','G','D','E','F']. Then the polybius square would look like ...

__ A Z C D E F
A| o r 0 a n 3
B| g e b c d f
G| h i j k l m
D| p q s t u v
E| w x y z 1 2
F| 4 5 6 7 8 9

Basic usage:

use cipher_crypt::{Cipher, Polybius};

let p = Polybius::new((String::from("or0an3ge"), ['A','Z','C','D','E','F'],
    ['A','B','G','D','E','F'])).unwrap();

assert_eq!("EEAC AAazadaebabzdc adaebe EF ADdadagebzdc!",
   p.encrypt("10 Oranges and 2 Apples!").unwrap());

Encrypt a message using a Polybius square cipher.

Examples

Basic usage:

use cipher_crypt::{Cipher, Polybius};

let p = Polybius::new((String::from("p0lyb1us"), ['A','Z','C','D','E','F'],
    ['A','B','G','D','E','F'])).unwrap();

assert_eq!("BCdfdfbcbdgf 🗡️ dfgcbf bfbcbzdf ezbcacac",
   p.encrypt("Attack 🗡️ the east wall").unwrap());

Decrypt a message using a Polybius square cipher.

Examples

Basic usage:

use cipher_crypt::{Cipher, Polybius};

let p = Polybius::new((String::from("p0lyb1us"), ['A','Z','C','D','E','F'],
    ['A','B','G','D','E','F'])).unwrap();

assert_eq!("Attack 🗡️ the east wall",
   p.decrypt("BCdfdfbcbdgf 🗡️ dfgcbf bfbcbzdf ezbcacac").unwrap());