pub struct VigenereNoTable {
    pub alphabet: Arc<Alphabet>,
    pub sorted_alphabet: Vec<Vec<u8>>,
}

Fields§

§alphabet: Arc<Alphabet>§sorted_alphabet: Vec<Vec<u8>>

Implementations§

source§

impl VigenereNoTable

source

pub fn new(alphabet: Arc<Alphabet>) -> Self

source

pub fn encrypt( &self, plain_text: Vec<u8>, passphrase_key: Vec<Vec<u8>> ) -> Vec<u8>

use cryptatools_core::utils::{alphabets, alphabets::Alphabet, convert::Encode};
use cryptatools_core::cryptography::classical::encryption::polyalphabetic_ciphers::vigenere::VigenereNoTable;
let ascii_alphabet = Alphabet::new_empty().ascii_encoding();
let v = VigenereNoTable::new(ascii_alphabet.clone().into());
let plaintext = Encode::from_ascii_to_u8(String::from("the quick brown roman fox jumped over the lazy ostrogoth dog"));
 
assert_eq!(plaintext, [116, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 114, 111, 109, 97, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 101, 100, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 111, 115, 116, 114, 111, 103, 111, 116, 104, 32, 100, 111, 103]);
 
let key = alphabets::split_bytes_by_characters_representation(&ascii_alphabet.clone(), Encode::from_ascii_to_u8(String::from("caesar")));
 
assert_eq!(key, [[99], [97], [101], [115], [97], [114]]);
 
let result = v.encrypt(plaintext, key);
 
assert_eq!(result, [86, 72, 73, 18, 81, 102, 75, 67, 79, 18, 66, 99, 81, 87, 82, 18, 82, 96, 79, 65, 82, 18, 70, 96, 90, 0, 78, 103, 77, 97, 71, 68, 4, 97, 86, 86, 84, 0, 88, 90, 69, 17, 78, 65, 94, 107, 0, 96, 85, 84, 86, 97, 71, 96, 86, 72, 4, 86, 79, 88]);
 
use cryptatools_core::utils::convert::Decode;
let str_encrypted = Decode::from_u8_to_ascii(result);
 
assert_eq!(str_encrypted, "VHI\u{12}QfKCO\u{12}BcQWR\u{12}R`OAR\u{12}F`Z\0NgMaGD\u{4}aVVT\0XZE\u{11}NA^k\0`UTVaG`VH\u{4}VOX");
 
let uppurcase_ascii_alphabet_with_no_chars = Alphabet::new_empty().uppercase_no_space_ascii_alphabet_encoding();
let v = VigenereNoTable::new(uppurcase_ascii_alphabet_with_no_chars.clone().into());
let plaintext = Encode::from_ascii_to_u8(String::from("thequickbrownromanfoxjumpedoverthelazyostrogothdog").to_uppercase());
let key = alphabets::split_bytes_by_characters_representation(&uppurcase_ascii_alphabet_with_no_chars.clone().into(), Encode::from_ascii_to_u8(String::from("CAESAR")));
assert_eq!(plaintext, [84, 72, 69, 81, 85, 73, 67, 75, 66, 82, 79, 87, 78, 82, 79, 77, 65, 78, 70, 79, 88, 74, 85, 77, 80, 69, 68, 79, 86, 69, 82, 84, 72, 69, 76, 65, 90, 89, 79, 83, 84, 82, 79, 71, 79, 84, 72, 68, 79, 71]);
assert_eq!(key, [[67], [65], [69], [83], [65], [82]]);
 
let result = v.encrypt(plaintext, key);
 
assert_eq!(result, [86, 72, 73, 73, 85, 90, 69, 75, 70, 74, 79, 78, 80, 82, 83, 69, 65, 69, 72, 79, 66, 66, 85, 68, 82, 69, 72, 71, 86, 86, 84, 84, 76, 87, 76, 82, 66, 89, 83, 75, 84, 73, 81, 71, 83, 76, 72, 85, 81, 71]);
 
let str_encrypted = Decode::from_u8_to_ascii(result);
assert_eq!(str_encrypted, "VHIIUZEKFJONPRSEAEHOBBUDREHGVVTTLWLRBYSKTIQGSLHUQG");

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V