pub struct Base32;Expand description
Standard Base32 encoder and decoder with padding.
This implementation follows the standard Base32 encoding as defined in RFC 4648, and includes padding characters (‘=’) when needed.
§Standard Base32 Alphabet
The standard Base32 alphabet uses characters:
- ‘A’ to ‘Z’ (26 characters, values 0-25)
- ‘2’ to ‘7’ (6 characters, values 26-31)
- ‘=’ (padding character)
§Examples
use ct_codecs::{Base32, Encoder, Decoder};
fn example() -> Result<(), ct_codecs::Error> {
let data = b"foobar";
let encoded = Base32::encode_to_string(data)?;
assert_eq!(encoded, "MZXW6YTBOI======");
let decoded = Base32::decode_to_vec(&encoded, None)?;
assert_eq!(decoded, data);
Ok(())
}Trait Implementations§
Source§impl Decoder for Base32
impl Decoder for Base32
Source§impl Encoder for Base32
impl Encoder for Base32
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 Base32
impl RefUnwindSafe for Base32
impl Send for Base32
impl Sync for Base32
impl Unpin for Base32
impl UnsafeUnpin for Base32
impl UnwindSafe for Base32
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