logo
pub struct Iso10126;
Expand description

Pad block with arbitrary bytes ending with value equal to the number of bytes added.

A variation of PKCS#7 that is less strict when decoding.

use block_padding::{Iso10126, 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);
Iso10126::pad(&mut block, pos);
assert_eq!(&block[..], b"test\x04\x04\x04\x04");
let res = Iso10126::unpad(&block).unwrap();
assert_eq!(res, msg);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Padding type

Pads block filled with data up to pos (i.e length of a message stored in the block is equal to pos). Read more

Unpad data in the block. Read more

Unpad data in the blocks. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.