Struct ultra::Enigma
[−]
[src]
pub struct Enigma { /* fields omitted */ }
Methods
impl Enigma
[src]
fn new(rotors: &str,
keys: &str,
rings: &str,
reflector: char,
plugboard: &str)
-> Enigma
keys: &str,
rings: &str,
reflector: char,
plugboard: &str)
-> Enigma
Creates a new Enigma
, where rotors
is a string of three digits
ranging from 1-8 (corresponding to rotors I through VIII of the real
Enigma machine), keys
and rings
are three character strings
containing the key and ring settings, reflector
is one of 'A'
,
'B'
, or 'C'
, and plugboard
is a string of whitespace-delimited
pairs of characters.
Examples
Enigma
with rotors I, II, and III, key setting ABC
, ring setting
DEF
, reflector B, and a plugboard connection between 'P' and 'Y'.
use ultra::Enigma; let mut enigma = Enigma::new("123", "ABC", "DEF", 'B', "PY"); println!("{}", enigma.encrypt("ENIGMA"));
fn encrypt(&mut self, msg: &str) -> String
Encrypts an entire message, advancing the rotors of the machine after each alphabetic character is encrypted.
fn encrypt_char(&mut self, c: char) -> char
Advances the rotors then returns the substitution of a character, if the input character was alphabetic.
fn reset(&mut self)
Resets the Enigma
to its initial state.
Trait Implementations
impl Clone for Enigma
[src]
fn clone(&self) -> Enigma
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more