const ORACLE_SEED: u64 = 0x51_7c_c1_b7_27_22_0a_95;
#[must_use]
#[allow(clippy::indexing_slicing)]
pub fn naive_hash64(bytes: &[u8]) -> u64 {
#[allow(clippy::indexing_slicing)]
let mut state: u64 = 0;
let mut idx = 0usize;
while idx + 8 <= bytes.len() {
let mut chunk: u64 = 0;
for (shift, b) in bytes[idx..idx + 8].iter().enumerate() {
chunk |= u64::from(*b) << (8 * shift);
}
state = (state.rotate_left(5) ^ chunk).wrapping_mul(ORACLE_SEED);
idx += 8;
}
while idx < bytes.len() {
state = (state.rotate_left(5) ^ u64::from(bytes[idx])).wrapping_mul(ORACLE_SEED);
idx += 1;
}
state ^= state >> 33;
state = state.wrapping_mul(0xFF51_AFD7_ED55_8CCD);
state ^= state >> 33;
state = state.wrapping_mul(0xC4CE_B9FE_1A85_EC53);
state ^= state >> 33;
state
}
#[must_use]
pub fn naive_stream_hash(a: &[u8], b: &[u8]) -> u64 {
let mut joined = alloc::vec::Vec::with_capacity(a.len().saturating_add(b.len()));
joined.extend_from_slice(a);
joined.extend_from_slice(b);
naive_hash64(&joined)
}