Function nix_compat::store_path::compress_hash
source · pub fn compress_hash<const OUTPUT_SIZE: usize>(
input: &[u8],
) -> [u8; OUTPUT_SIZE]
Expand description
compress_hash takes an arbitrarily long sequence of bytes (usually a hash digest), and returns a sequence of bytes of length OUTPUT_SIZE.
It’s calculated by rotating through the bytes in the output buffer (zero- initialized), and XOR’ing with each byte of the passed input. It consumes 1 byte at a time, and XOR’s it with the current value in the output buffer.
This mimics equivalent functionality in C++ Nix.