pub struct VigenereCipher { /* private fields */ }Expand description
A Vigenere cipher implementation.
This cipher uses a keyword to perform a series of Caesar ciphers on the plaintext. It is a classic example of a polyalphabetic substitution cipher.
Implementations§
Trait Implementations§
Source§impl Block for VigenereCipher
impl Block for VigenereCipher
Source§fn block_size(&self) -> usize
fn block_size(&self) -> usize
Returns the length of the Vigenere key.
Source§fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
fn encrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
Encrypts source bytes into destination buffer using the Vigenere cipher.
This method maps source characters ‘A’-‘Z’ to values 0-25, applies the Vigenere shift from the key, and then maps the result back to uppercase letters. Non-alphabetic characters are currently handled by applying the shift to their raw ASCII value, though most usage expects only ‘A’-‘Z’ input.
§Arguments
dst- The destination buffer for the encrypted bytes.src- The source plaintext bytes to encrypt.
§Returns
Returns the number of bytes written to dst.
Source§fn decrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
fn decrypt(&self, dst: &mut [u8], src: &[u8]) -> usize
Decrypts source bytes into destination buffer using the Vigenere cipher.
This method reverses the Vigenere shift by subtracting the key values from the ciphertext values modulo 26.
§Arguments
dst- The destination buffer for the decrypted bytes.src- The source ciphertext bytes to decrypt.
§Returns
Returns the number of bytes written to dst.