何度やっても同じ値になります。使い勝手は良さそう。
use std::hash::{DefaultHasher, Hash, Hasher}; fn siphash13(s: String) { let mut siphash = DefaultHasher::new(); s.hash(&mut siphash); println!("{:?}", siphash.finish()); println!("{:?}", siphash); } fn main(){ let mut t = "hello wolrd".to_string(); siphash13(t); }
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
Running `target/debug/wallet`
397376489521336075
DefaultHasher(SipHasher13 { hasher: Hasher { k0: 0, k1: 0, length: 12, state: State { v0: 14783544211356068956, v2: 15472093343132851580, v1: 2669010635360672206, v3: 8002614515094862307 }, tail: 4284772972, ntail: 4, _marker: PhantomData