Struct cryptatools_core::utils::alphabets::Alphabet
source · pub struct Alphabet {
pub encoding: BiBTreeMap<String, Vec<u8>>,
}
Fields§
§encoding: BiBTreeMap<String, Vec<u8>>
Alphabet encoding.
Implementations§
source§impl Alphabet
impl Alphabet
pub fn new(encoding: Vec<Encoding>) -> Self
pub fn new_empty() -> Self
sourcepub fn ascii_printable_only_encoding(&mut self) -> Self
pub fn ascii_printable_only_encoding(&mut self) -> Self
Builder to add encoding to the encoding.
pub fn ascii_encoding(&mut self) -> Self
pub fn pokered_charset_encoding(&mut self) -> Self
pub fn uppercase_no_space_ascii_alphabet_encoding(&mut self) -> Self
pub fn intel_x86_32_encoding(&mut self) -> Self
sourcepub fn unknow_opcodes(&mut self) -> Self
pub fn unknow_opcodes(&mut self) -> Self
Unknow opcodes
Use this alphabet to make statistics on stream cipher when you ignore the assembly langauge or natural language.
sourcepub fn full_hexadecimal_alphabet() -> Self
pub fn full_hexadecimal_alphabet() -> Self
Full Hexadecimal (0x00-0xff)
Use this alphabet if you are working on hash because the hash are often hexadecimal. The alphabet is from hex string to the corresponding ascii value in hex byte value.
This method has no argument. Returns an alphabet made with hexadecimal and lowercase only values.
sourcepub fn hexadecimal_ascii_lowercase_sixteen_bits_alphabet() -> Self
pub fn hexadecimal_ascii_lowercase_sixteen_bits_alphabet() -> Self
Ascii lowercase hexadecimal alphabet
Use this alphabet if you are working on hash because the hash are often hexadecimal. The alphabet is from hex string to the corresponding ascii value in hex byte value.
This method has no argument. Returns an alphabet made with hexadecimal and lowercase only values.
sourcepub fn extended_ascii_encoding(&mut self) -> Self
pub fn extended_ascii_encoding(&mut self) -> Self
Extended ascii alphabet.
Contains 256 values of ascii character. This is the default alphabet that you should use when working on networking packets, program file or assembly language.
This method has no argument. Returns an alphabet made with extended ascii values..
pub fn get_encoding(&self) -> Vec<Encoding>
sourcepub fn decode(&self, encoded: Vec<u8>) -> Vec<Encoding>
pub fn decode(&self, encoded: Vec<u8>) -> Vec<Encoding>
Convert opcodes to an human readable set of characters text in the same order as the original unconverted text.
Once deciphered in plain characters, a cryptographic algorithm still need to be seen in a decodable format. This is why this method returns a Vector of Encoded
struct.
paramaters:
- encoding: opcode vector to convert to a set of character.
Returns: a converted human readable set of character text in the same order as the original unconverted text.
use cryptatools_core::utils::{convert::Encode, alphabets::split_bytes_by_characters_representation, alphabets::Alphabet};
use cryptatools_core::utils::alphabets::Encoding;
let ascii_alphabet = Alphabet::new_empty().ascii_encoding();
let alph = ascii_alphabet.decode(vec![0x41, 0x41, 0x42, 0x42]);
let decoded = vec![Encoding{str: String::from("A"), bytes: vec![0x41]}, Encoding{str: String::from("A"), bytes: vec![0x41]}, Encoding{str: String::from("B"), bytes: vec![0x42]}, Encoding{str: String::from("B"), bytes: vec![0x42]}];
assert_eq!(alph, decoded);