Struct ultra::Enigma [−][src]
Implementations
impl Enigma
[src]
pub fn new(
rotors: &str,
keys: &str,
rings: &str,
reflector: char,
plugboard: &str
) -> Enigma
[src]
rotors: &str,
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"));
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,