pub struct HashX { /* private fields */ }
Expand description
Pre-built hash program that can be rapidly computed with different inputs
The program and initial state representation are not specified in this
public interface, but std::fmt::Debug
can describe program internals.
Implementations§
Source§impl HashX
impl HashX
Sourcepub const FULL_SIZE: usize = 32usize
pub const FULL_SIZE: usize = 32usize
The maximum available output size for Self::hash_to_bytes()
Sourcepub fn new(seed: &[u8]) -> Result<Self, Error>
pub fn new(seed: &[u8]) -> Result<Self, Error>
Generate a new hash function with the supplied seed.
Sourcepub fn runtime(&self) -> Runtime
pub fn runtime(&self) -> Runtime
Check which actual program runtime is in effect.
By default we try to generate code at runtime to accelerate the hash
function, but we fall back to an interpreter if this fails. The compiler
can be disabled entirely using RuntimeOption::InterpretOnly
and
HashXBuilder
.
Sourcepub fn hash_to_u64(&self, input: u64) -> u64
pub fn hash_to_u64(&self, input: u64) -> u64
Calculate the first 64-bit word of the hash, without converting to bytes.
Sourcepub fn hash_to_bytes(&self, input: u64) -> [u8; 32]
pub fn hash_to_bytes(&self, input: u64) -> [u8; 32]
Calculate the hash function at its full output width, returning a fixed size byte array.