Enum block_padding::ZeroPadding
source · [−]pub enum ZeroPadding {}
Expand description
Pad block with zeros.
use block_padding::{ZeroPadding, Padding};
let msg = b"test";
let n = msg.len();
let mut buffer = [0xff; 16];
buffer[..n].copy_from_slice(msg);
let padded_msg = ZeroPadding::pad(&mut buffer, n, 8).unwrap();
assert_eq!(padded_msg, b"test\x00\x00\x00\x00");
assert_eq!(ZeroPadding::unpad(&padded_msg).unwrap(), msg);
let padded_msg = ZeroPadding::pad(&mut buffer, n, 2).unwrap();
assert_eq!(padded_msg, b"test");
assert_eq!(ZeroPadding::unpad(&padded_msg).unwrap(), msg);
Note that zero padding may not be reversible if the original message ends with one or more zero bytes.
Trait Implementations
sourceimpl Padding for ZeroPadding
impl Padding for ZeroPadding
Auto Trait Implementations
impl RefUnwindSafe for ZeroPadding
impl Send for ZeroPadding
impl Sync for ZeroPadding
impl Unpin for ZeroPadding
impl UnwindSafe for ZeroPadding
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more