zest4096 0.1.27

ChaCha based hash for faster, larger blocks
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::zest_block::{bytes_to_blocks, ZestBlock};

// Takes in arbitrary length input and pads it to needed length.
#[inline(always)]
pub fn pad_bytes(input: &[u8]) -> Vec<ZestBlock> {
    let mut un_padded = input.to_vec();
    un_padded.push(0xFF);
    let alignment_add = 0x200 - (un_padded.len() & 0x1FF);
    un_padded.resize(un_padded.len() + alignment_add, 0);
    bytes_to_blocks(un_padded)
}

// Takes in blocks and de-pads it back to original size.
#[inline(always)]
pub fn depad_bytes(input: &mut Vec<u8>) {
    while input.pop() == Some(0) {}
}