pub struct Base32Hex;Expand description
Base32 Hex encoder and decoder with padding.
This implementation follows the Base32hex encoding variant as defined in RFC 4648. It uses the extended hex alphabet (0-9, A-V) instead of the standard base32 alphabet. Padding characters (‘=’) are included when needed.
§Base32hex Alphabet
The Base32hex alphabet uses characters:
- ‘0’ to ‘9’ (10 characters, values 0-9)
- ‘A’ to ‘V’ (22 characters, values 10-31)
- ‘=’ (padding character)
§Examples
use ct_codecs::{Base32Hex, Encoder, Decoder};
fn example() -> Result<(), ct_codecs::Error> {
let data = b"foobar";
let encoded = Base32Hex::encode_to_string(data)?;
assert_eq!(encoded, "CPNMUOJ1E8======");
let decoded = Base32Hex::decode_to_vec(&encoded, None)?;
assert_eq!(decoded, data);
Ok(())
}Trait Implementations§
Source§impl Decoder for Base32Hex
impl Decoder for Base32Hex
Source§impl Encoder for Base32Hex
impl Encoder for Base32Hex
Source§fn encoded_len(bin_len: usize) -> Result<usize, Error>
fn encoded_len(bin_len: usize) -> Result<usize, Error>
Calculates the length of the encoded output for a given binary input length. Read more
Source§fn encode<IN: AsRef<[u8]>>(b32: &mut [u8], bin: IN) -> Result<&[u8], Error>
fn encode<IN: AsRef<[u8]>>(b32: &mut [u8], bin: IN) -> Result<&[u8], Error>
Encodes binary data into a text representation. Read more
Auto Trait Implementations§
impl Freeze for Base32Hex
impl RefUnwindSafe for Base32Hex
impl Send for Base32Hex
impl Sync for Base32Hex
impl Unpin for Base32Hex
impl UnsafeUnpin for Base32Hex
impl UnwindSafe for Base32Hex
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