Struct ultra::Enigma[][src]

pub struct Enigma { /* fields omitted */ }

Implementations

impl Enigma[src]

pub fn new(
    rotors: &str,
    keys: &str,
    rings: &str,
    reflector: char,
    plugboard: &str
) -> Enigma
[src]

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"));

pub fn random() -> Enigma[src]

Creates a new random Enigma with random settings based on thread-local RNG.

use ultra::Enigma;

let mut enigma = Enigma::random();
println!("{}", enigma.encrypt("ENIGMA"));

pub fn random_from_u64_seed(seed: u64) -> Enigma[src]

Creates a new random Enigma from a given u64 seed.

use ultra::Enigma;

let mut enigma_1 = Enigma::random_from_u64_seed(42);
let mut enigma_2 = Enigma::random_from_u64_seed(42);
assert_eq!(enigma_1.encrypt("ENIGMA"), enigma_2.encrypt("ENIGMA"));

pub fn random_from_rng<R: Rng>(rng: &mut R) -> Enigma[src]

pub fn encrypt(&mut self, msg: &str) -> String[src]

Encrypts an entire message, advancing the rotors of the machine after each alphabetic character is encrypted.

pub fn encrypt_char(&mut self, c: char) -> char[src]

Advances the rotors then returns the substitution of a character, if the input character was alphabetic.

pub fn reset(&mut self)[src]

Resets the Enigma to its initial state.

Trait Implementations

impl Clone for Enigma[src]

impl Debug for Enigma[src]

impl Display for Enigma[src]

Auto Trait Implementations

impl RefUnwindSafe for Enigma

impl Send for Enigma

impl Sync for Enigma

impl Unpin for Enigma

impl UnwindSafe for Enigma

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,