Struct cryptatools_core::utils::convert::Encode
source · pub struct Encode {}
Implementations§
source§impl Encode
impl Encode
sourcepub fn from_ascii_to_u8(ascii_input: String) -> Vec<u8> ⓘ
pub fn from_ascii_to_u8(ascii_input: String) -> Vec<u8> ⓘ
Encode a string to a vector of u8 bytes.
use cryptatools_core::utils::convert;
let bytes: Vec<u8> = convert::Encode::from_ascii_to_u8(String::from("AAA"));
assert_eq!(vec![0x41, 0x41, 0x41], bytes);
sourcepub fn encode(alphabet: &Alphabet, unecoded: String) -> Vec<u8> ⓘ
pub fn encode(alphabet: &Alphabet, unecoded: String) -> Vec<u8> ⓘ
Encode the input argument unencoded
to a byte according the alphabet
.
use cryptatools_core::utils::convert;
use cryptatools_core::utils::alphabets::{Alphabet};
let ascii_alphabet = Alphabet::new_empty().ascii_encoding();
let encoded: Vec<u8> = convert::Encode::encode(&ascii_alphabet, String::from("ABCDEFGH"));
assert_eq!(encoded, vec![65, 66, 67, 68, 69, 70, 71, 72]);
let pokered_alphabet = Alphabet::new_empty().pokered_charset_encoding();
let pokered_encoded = convert::Encode::encode(&pokered_alphabet, String::from("<NULL><PAGE><PKMN>"));
assert_eq!(pokered_encoded, vec![0, 73, 74]);
Auto Trait Implementations§
impl RefUnwindSafe for Encode
impl Send for Encode
impl Sync for Encode
impl Unpin for Encode
impl UnwindSafe for Encode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more