Function keccak_hash::keccak256_range [−][src]
pub fn keccak256_range(data: &mut [u8], range: Range<usize>)
Computes in-place keccak256 hash of data[range]
.
The range
argument specifies a subslice of data
in bytes to be hashed.
The resulting hash will be written back to data
.
Panics
If range
is out of bounds.
Example
let mut data = [1u8; 32]; // Hash the first 8 bytes of `data` and write the result, 32 bytes, to `data`. keccak_hash::keccak256_range(&mut data, 0..8); let expected = [ 0x54, 0x84, 0x4f, 0x69, 0xb4, 0xda, 0x4b, 0xb4, 0xa9, 0x9f, 0x24, 0x59, 0xb5, 0x11, 0xd4, 0x42, 0xcc, 0x5b, 0xd2, 0xfd, 0xf4, 0xc3, 0x54, 0xd2, 0x07, 0xbb, 0x13, 0x08, 0x94, 0x43, 0xaf, 0x68, ]; assert_eq!(&data, &expected);