use std::hash::Hasher;
#[cfg(feature = "cpu")]
use ihash::cpu;
use ihash::{
HashMap, HashMapExt, HashSet, HashSetExt, IHasher, Stream, hash_xof, hash32, hash64, hash128,
hash256, seed,
};
fn main() {
let msg = b"Hello World";
println!("hash32 = 0x{:08x}", hash32(msg));
println!("hash64 = 0x{:016x}", hash64(msg));
println!("hash128 = 0x{:032x}", hash128(msg));
println!("hash256 = {:02x?}", &hash256(msg)[..8]);
let mut xof_li = [0u8; 64];
hash_xof(msg, &mut xof_li);
println!("xof[..8]= {:02x?}", &xof_li[..8]);
println!("seed64 = 0x{:016x}", seed::hash64(msg, 42));
let mut buf_li = *b"fast non-cryptographic stream cipher";
let mut enc = seed::keystream(12345);
enc.xor_keystream(&mut buf_li);
let mut dec = seed::keystream(12345);
dec.xor_keystream(&mut buf_li);
println!("stream = {}", String::from_utf8_lossy(&buf_li));
let mut key_stream = Stream::new(msg);
key_stream.xor_keystream(&mut buf_li[..8]);
let mut hasher = IHasher::new();
hasher.write(msg);
hasher.write_u64(12345);
println!("hasher = 0x{:016x}", hasher.finish());
let mut map: HashMap<&str, usize> = HashMap::new();
map.insert("ihash", 1);
let mut set: HashSet<&str> = HashSet::new();
set.insert("ihash");
println!(
"map/set = {:?} / {}",
map.get("ihash"),
set.contains("ihash")
);
#[cfg(feature = "cpu")]
println!("cpu64 = 0x{:016x}", cpu::hash64(msg));
}