sha3_utils

Function bytepad

Source
pub fn bytepad<const W: usize>(s: EncodedString<'_>) -> BytePad<'_, W>
Expand description

Prepends the integer encoding of W to s, then pads the result to a multiple of W.

§Preconditions

  • W must be non-zero.

§Example

use sha3_utils::{bytepad, encode_string};

let v = bytepad::<32>(encode_string(b"hello, world!"));
assert_eq!(
    v.iter().flatten().copied().collect::<Vec<_>>(),
    &[
        1, 32,
        1, 104,
        104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    ],
);