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 Freeze for Encode
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
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§fn clone_handle(handle: Handle) -> Handle
fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more