pub struct UncheckedEnigmaMachine { /* private fields */ }
Implementations§
Source§impl UncheckedEnigmaMachine
impl UncheckedEnigmaMachine
Sourcepub unsafe fn decrypt_unchecked(&self, text: &str) -> String
pub unsafe fn decrypt_unchecked(&self, text: &str) -> String
Decrypts the given ciphertext while skipping all safety checks for maxmimum speed.
This is exactly the same as calling machine.encrypt_unchecked(text)
, since the enigma cipher is
symmetric; The only difference is semantic meaning and intent, i.e.,
assert_eq!(text, machine.decrypt_unchecked(machine.decrypt_unchecked(text)));
assert_eq!(text, machine.encrypt_unchecked(machine.encrypt_unchecked(text)));
assert_eq!(text, machine.decrypt_unchecked(machine.encrypt_unchecked(text)));
assert_eq!(text, machine.encrypt_unchecked(machine.decrypt_unchecked(text)));
§Parameters
text
- The ciphertext to decrypt
§Returns
The decrypted plaintext.
§Safety
This function may panic if the Enigma machine was constructed with invalid settings. If the machine was constructed
correctly, this is guarnateed to not panic, and will function identically to EnigmaMachine::decrypt()
, with
marginally better performance. See the Performance
section of the README
for more information.
Sourcepub unsafe fn encrypt_unchecked(&self, text: &str) -> String
pub unsafe fn encrypt_unchecked(&self, text: &str) -> String
Encrypts the given plaintext while skipping all safety checks for maxmimum speed.
This is exactly the same as calling machine.decrypt_unchecked(text)
, since the enigma cipher is
symmetric; The only difference is semantic meaning and intent, i.e.,
assert_eq!(text, machine.decrypt_unchecked(machine.decrypt_unchecked(text)));
assert_eq!(text, machine.encrypt_unchecked(machine.encrypt_unchecked(text)));
assert_eq!(text, machine.decrypt_unchecked(machine.encrypt_unchecked(text)));
assert_eq!(text, machine.encrypt_unchecked(machine.decrypt_unchecked(text)));
§Parameters
text
- The ciphertext to decrypt
§Returns
The decrypted plaintext.
§Safety
This function may panic if the Enigma machine was constructed with invalid settings. If the machine was constructed
correctly, this is guarnateed to not panic, and will function identically to EnigmaMachine::decrypt()
, with
marginally better performance. See the Performance
section of the README
for more information.
Trait Implementations§
Source§impl UncheckedEnigmaBuilder for UncheckedEnigmaMachine
impl UncheckedEnigmaBuilder for UncheckedEnigmaMachine
Source§fn rotors(self, first: u8, second: u8, third: u8) -> impl UncheckedEnigmaBuilder
fn rotors(self, first: u8, second: u8, third: u8) -> impl UncheckedEnigmaBuilder
Source§fn ring_positions(
self,
first: u8,
second: u8,
third: u8,
) -> impl UncheckedEnigmaBuilder
fn ring_positions( self, first: u8, second: u8, third: u8, ) -> impl UncheckedEnigmaBuilder
Source§fn ring_settings(
self,
first: u8,
second: u8,
third: u8,
) -> impl UncheckedEnigmaBuilder
fn ring_settings( self, first: u8, second: u8, third: u8, ) -> impl UncheckedEnigmaBuilder
Source§fn plugboard(self, plugboard: &str) -> impl UncheckedEnigmaBuilder
fn plugboard(self, plugboard: &str) -> impl UncheckedEnigmaBuilder
AY
will map A
to Y
and also Y
to A
. Read moreSource§fn reflector(self, reflector: &str) -> impl UncheckedEnigmaBuilder
fn reflector(self, reflector: &str) -> impl UncheckedEnigmaBuilder
Source§fn build(self) -> UncheckedEnigmaMachine
fn build(self) -> UncheckedEnigmaMachine
impl UncheckedEnigmaBuilder
opaque type into the concrete EnigmaMachine
by just returning self
.