Struct block_padding::AnsiX923
source · [−]pub struct AnsiX923;
Expand description
Pad block with zeros except the last byte which will be set to the number bytes.
use block_padding::{AnsiX923, Padding};
use generic_array::{GenericArray, typenum::U8};
let msg = b"test";
let pos = msg.len();
let mut block: GenericArray::<u8, U8> = [0xff; 8].into();
block[..pos].copy_from_slice(msg);
AnsiX923::pad(&mut block, pos);
assert_eq!(&block[..], b"test\x00\x00\x00\x04");
let res = AnsiX923::unpad(&block).unwrap();
assert_eq!(res, msg);
Trait Implementations
sourceimpl<B: ArrayLength<u8>> Padding<B> for AnsiX923
impl<B: ArrayLength<u8>> Padding<B> for AnsiX923
impl Copy for AnsiX923
Auto Trait Implementations
impl RefUnwindSafe for AnsiX923
impl Send for AnsiX923
impl Sync for AnsiX923
impl Unpin for AnsiX923
impl UnwindSafe for AnsiX923
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more