1 | //! An implementation of the [Fowler–Noll–Vo hash function][chongo]. |
2 | //! |
3 | //! ## About |
4 | //! |
5 | //! The FNV hash function is a custom `Hasher` implementation that is more |
6 | //! efficient for smaller hash keys. |
7 | //! |
8 | //! [The Rust FAQ states that][faq] while the default `Hasher` implementation, |
9 | //! SipHash, is good in many cases, it is notably slower than other algorithms |
10 | //! with short keys, such as when you have a map of integers to other values. |
11 | //! In cases like these, [FNV is demonstrably faster][graphs]. |
12 | //! |
13 | //! Its disadvantages are that it performs badly on larger inputs, and |
14 | //! provides no protection against collision attacks, where a malicious user |
15 | //! can craft specific keys designed to slow a hasher down. Thus, it is |
16 | //! important to profile your program to ensure that you are using small hash |
17 | //! keys, and be certain that your program could not be exposed to malicious |
18 | //! inputs (including being a networked server). |
19 | //! |
20 | //! The Rust compiler itself uses FNV, as it is not worried about |
21 | //! denial-of-service attacks, and can assume that its inputs are going to be |
22 | //! small—a perfect use case for FNV. |
23 | //! |
24 | #![cfg_attr (feature = "std" , doc = r#" |
25 | |
26 | ## Using FNV in a `HashMap` |
27 | |
28 | The `FnvHashMap` type alias is the easiest way to use the standard library’s |
29 | `HashMap` with FNV. |
30 | |
31 | ```rust |
32 | use fnv::FnvHashMap; |
33 | |
34 | let mut map = FnvHashMap::default(); |
35 | map.insert(1, "one"); |
36 | map.insert(2, "two"); |
37 | |
38 | map = FnvHashMap::with_capacity_and_hasher(10, Default::default()); |
39 | map.insert(1, "one"); |
40 | map.insert(2, "two"); |
41 | ``` |
42 | |
43 | Note, the standard library’s `HashMap::new` and `HashMap::with_capacity` |
44 | are only implemented for the `RandomState` hasher, so using `Default` to |
45 | get the hasher is the next best option. |
46 | |
47 | ## Using FNV in a `HashSet` |
48 | |
49 | Similarly, `FnvHashSet` is a type alias for the standard library’s `HashSet` |
50 | with FNV. |
51 | |
52 | ```rust |
53 | use fnv::FnvHashSet; |
54 | |
55 | let mut set = FnvHashSet::default(); |
56 | set.insert(1); |
57 | set.insert(2); |
58 | |
59 | set = FnvHashSet::with_capacity_and_hasher(10, Default::default()); |
60 | set.insert(1); |
61 | set.insert(2); |
62 | ``` |
63 | "# )] |
64 | //! |
65 | //! [chongo]: http://www.isthe.com/chongo/tech/comp/fnv/index.html |
66 | //! [faq]: https://www.rust-lang.org/en-US/faq.html#why-are-rusts-hashmaps-slow |
67 | //! [graphs]: https://cglab.ca/~abeinges/blah/hash-rs/ |
68 | |
69 | #![cfg_attr (not(feature = "std" ), no_std)] |
70 | |
71 | #[cfg (all(not(feature = "std" ), test))] |
72 | extern crate alloc; |
73 | |
74 | #[cfg (feature = "std" )] |
75 | use std::default::Default; |
76 | #[cfg (feature = "std" )] |
77 | use std::hash::{Hasher, BuildHasherDefault}; |
78 | #[cfg (feature = "std" )] |
79 | use std::collections::{HashMap, HashSet}; |
80 | #[cfg (not(feature = "std" ))] |
81 | use core::default::Default; |
82 | #[cfg (not(feature = "std" ))] |
83 | use core::hash::{Hasher, BuildHasherDefault}; |
84 | |
85 | /// An implementation of the Fowler–Noll–Vo hash function. |
86 | /// |
87 | /// See the [crate documentation](index.html) for more details. |
88 | #[allow (missing_copy_implementations)] |
89 | pub struct FnvHasher(u64); |
90 | |
91 | impl Default for FnvHasher { |
92 | |
93 | #[inline ] |
94 | fn default() -> FnvHasher { |
95 | FnvHasher(0xcbf29ce484222325) |
96 | } |
97 | } |
98 | |
99 | impl FnvHasher { |
100 | /// Create an FNV hasher starting with a state corresponding |
101 | /// to the hash `key`. |
102 | #[inline ] |
103 | pub fn with_key(key: u64) -> FnvHasher { |
104 | FnvHasher(key) |
105 | } |
106 | } |
107 | |
108 | impl Hasher for FnvHasher { |
109 | #[inline ] |
110 | fn finish(&self) -> u64 { |
111 | self.0 |
112 | } |
113 | |
114 | #[inline ] |
115 | fn write(&mut self, bytes: &[u8]) { |
116 | let FnvHasher(mut hash: u64) = *self; |
117 | |
118 | for byte: &u8 in bytes.iter() { |
119 | hash = hash ^ (*byte as u64); |
120 | hash = hash.wrapping_mul(0x100000001b3); |
121 | } |
122 | |
123 | *self = FnvHasher(hash); |
124 | } |
125 | } |
126 | |
127 | /// A builder for default FNV hashers. |
128 | pub type FnvBuildHasher = BuildHasherDefault<FnvHasher>; |
129 | |
130 | /// A `HashMap` using a default FNV hasher. |
131 | #[cfg (feature = "std" )] |
132 | pub type FnvHashMap<K, V> = HashMap<K, V, FnvBuildHasher>; |
133 | |
134 | /// A `HashSet` using a default FNV hasher. |
135 | #[cfg (feature = "std" )] |
136 | pub type FnvHashSet<T> = HashSet<T, FnvBuildHasher>; |
137 | |
138 | |
139 | #[cfg (test)] |
140 | mod test { |
141 | use super::*; |
142 | #[cfg (feature = "std" )] |
143 | use std::hash::Hasher; |
144 | #[cfg (not(feature = "std" ))] |
145 | use alloc::vec::Vec; |
146 | |
147 | fn fnv1a(bytes: &[u8]) -> u64 { |
148 | let mut hasher = FnvHasher::default(); |
149 | hasher.write(bytes); |
150 | hasher.finish() |
151 | } |
152 | |
153 | fn repeat_10(bytes: &[u8]) -> Vec<u8> { |
154 | (0..10).flat_map(|_| bytes.iter().cloned()).collect() |
155 | } |
156 | |
157 | fn repeat_500(bytes: &[u8]) -> Vec<u8> { |
158 | (0..500).flat_map(|_| bytes.iter().cloned()).collect() |
159 | } |
160 | |
161 | #[test ] |
162 | fn basic_tests() { |
163 | assert_eq!(fnv1a(b"" ), 0xcbf29ce484222325); |
164 | assert_eq!(fnv1a(b"a" ), 0xaf63dc4c8601ec8c); |
165 | assert_eq!(fnv1a(b"b" ), 0xaf63df4c8601f1a5); |
166 | assert_eq!(fnv1a(b"c" ), 0xaf63de4c8601eff2); |
167 | assert_eq!(fnv1a(b"d" ), 0xaf63d94c8601e773); |
168 | assert_eq!(fnv1a(b"e" ), 0xaf63d84c8601e5c0); |
169 | assert_eq!(fnv1a(b"f" ), 0xaf63db4c8601ead9); |
170 | assert_eq!(fnv1a(b"fo" ), 0x08985907b541d342); |
171 | assert_eq!(fnv1a(b"foo" ), 0xdcb27518fed9d577); |
172 | assert_eq!(fnv1a(b"foob" ), 0xdd120e790c2512af); |
173 | assert_eq!(fnv1a(b"fooba" ), 0xcac165afa2fef40a); |
174 | assert_eq!(fnv1a(b"foobar" ), 0x85944171f73967e8); |
175 | assert_eq!(fnv1a(b" \0" ), 0xaf63bd4c8601b7df); |
176 | assert_eq!(fnv1a(b"a \0" ), 0x089be207b544f1e4); |
177 | assert_eq!(fnv1a(b"b \0" ), 0x08a61407b54d9b5f); |
178 | assert_eq!(fnv1a(b"c \0" ), 0x08a2ae07b54ab836); |
179 | assert_eq!(fnv1a(b"d \0" ), 0x0891b007b53c4869); |
180 | assert_eq!(fnv1a(b"e \0" ), 0x088e4a07b5396540); |
181 | assert_eq!(fnv1a(b"f \0" ), 0x08987c07b5420ebb); |
182 | assert_eq!(fnv1a(b"fo \0" ), 0xdcb28a18fed9f926); |
183 | assert_eq!(fnv1a(b"foo \0" ), 0xdd1270790c25b935); |
184 | assert_eq!(fnv1a(b"foob \0" ), 0xcac146afa2febf5d); |
185 | assert_eq!(fnv1a(b"fooba \0" ), 0x8593d371f738acfe); |
186 | assert_eq!(fnv1a(b"foobar \0" ), 0x34531ca7168b8f38); |
187 | assert_eq!(fnv1a(b"ch" ), 0x08a25607b54a22ae); |
188 | assert_eq!(fnv1a(b"cho" ), 0xf5faf0190cf90df3); |
189 | assert_eq!(fnv1a(b"chon" ), 0xf27397910b3221c7); |
190 | assert_eq!(fnv1a(b"chong" ), 0x2c8c2b76062f22e0); |
191 | assert_eq!(fnv1a(b"chongo" ), 0xe150688c8217b8fd); |
192 | assert_eq!(fnv1a(b"chongo " ), 0xf35a83c10e4f1f87); |
193 | assert_eq!(fnv1a(b"chongo w" ), 0xd1edd10b507344d0); |
194 | assert_eq!(fnv1a(b"chongo wa" ), 0x2a5ee739b3ddb8c3); |
195 | assert_eq!(fnv1a(b"chongo was" ), 0xdcfb970ca1c0d310); |
196 | assert_eq!(fnv1a(b"chongo was " ), 0x4054da76daa6da90); |
197 | assert_eq!(fnv1a(b"chongo was h" ), 0xf70a2ff589861368); |
198 | assert_eq!(fnv1a(b"chongo was he" ), 0x4c628b38aed25f17); |
199 | assert_eq!(fnv1a(b"chongo was her" ), 0x9dd1f6510f78189f); |
200 | assert_eq!(fnv1a(b"chongo was here" ), 0xa3de85bd491270ce); |
201 | assert_eq!(fnv1a(b"chongo was here!" ), 0x858e2fa32a55e61d); |
202 | assert_eq!(fnv1a(b"chongo was here! \n" ), 0x46810940eff5f915); |
203 | assert_eq!(fnv1a(b"ch \0" ), 0xf5fadd190cf8edaa); |
204 | assert_eq!(fnv1a(b"cho \0" ), 0xf273ed910b32b3e9); |
205 | assert_eq!(fnv1a(b"chon \0" ), 0x2c8c5276062f6525); |
206 | assert_eq!(fnv1a(b"chong \0" ), 0xe150b98c821842a0); |
207 | assert_eq!(fnv1a(b"chongo \0" ), 0xf35aa3c10e4f55e7); |
208 | assert_eq!(fnv1a(b"chongo \0" ), 0xd1ed680b50729265); |
209 | assert_eq!(fnv1a(b"chongo w \0" ), 0x2a5f0639b3dded70); |
210 | assert_eq!(fnv1a(b"chongo wa \0" ), 0xdcfbaa0ca1c0f359); |
211 | assert_eq!(fnv1a(b"chongo was \0" ), 0x4054ba76daa6a430); |
212 | assert_eq!(fnv1a(b"chongo was \0" ), 0xf709c7f5898562b0); |
213 | assert_eq!(fnv1a(b"chongo was h \0" ), 0x4c62e638aed2f9b8); |
214 | assert_eq!(fnv1a(b"chongo was he \0" ), 0x9dd1a8510f779415); |
215 | assert_eq!(fnv1a(b"chongo was her \0" ), 0xa3de2abd4911d62d); |
216 | assert_eq!(fnv1a(b"chongo was here \0" ), 0x858e0ea32a55ae0a); |
217 | assert_eq!(fnv1a(b"chongo was here! \0" ), 0x46810f40eff60347); |
218 | assert_eq!(fnv1a(b"chongo was here! \n\0" ), 0xc33bce57bef63eaf); |
219 | assert_eq!(fnv1a(b"cu" ), 0x08a24307b54a0265); |
220 | assert_eq!(fnv1a(b"cur" ), 0xf5b9fd190cc18d15); |
221 | assert_eq!(fnv1a(b"curd" ), 0x4c968290ace35703); |
222 | assert_eq!(fnv1a(b"curds" ), 0x07174bd5c64d9350); |
223 | assert_eq!(fnv1a(b"curds " ), 0x5a294c3ff5d18750); |
224 | assert_eq!(fnv1a(b"curds a" ), 0x05b3c1aeb308b843); |
225 | assert_eq!(fnv1a(b"curds an" ), 0xb92a48da37d0f477); |
226 | assert_eq!(fnv1a(b"curds and" ), 0x73cdddccd80ebc49); |
227 | assert_eq!(fnv1a(b"curds and " ), 0xd58c4c13210a266b); |
228 | assert_eq!(fnv1a(b"curds and w" ), 0xe78b6081243ec194); |
229 | assert_eq!(fnv1a(b"curds and wh" ), 0xb096f77096a39f34); |
230 | assert_eq!(fnv1a(b"curds and whe" ), 0xb425c54ff807b6a3); |
231 | assert_eq!(fnv1a(b"curds and whey" ), 0x23e520e2751bb46e); |
232 | assert_eq!(fnv1a(b"curds and whey \n" ), 0x1a0b44ccfe1385ec); |
233 | assert_eq!(fnv1a(b"cu \0" ), 0xf5ba4b190cc2119f); |
234 | assert_eq!(fnv1a(b"cur \0" ), 0x4c962690ace2baaf); |
235 | assert_eq!(fnv1a(b"curd \0" ), 0x0716ded5c64cda19); |
236 | assert_eq!(fnv1a(b"curds \0" ), 0x5a292c3ff5d150f0); |
237 | assert_eq!(fnv1a(b"curds \0" ), 0x05b3e0aeb308ecf0); |
238 | assert_eq!(fnv1a(b"curds a \0" ), 0xb92a5eda37d119d9); |
239 | assert_eq!(fnv1a(b"curds an \0" ), 0x73ce41ccd80f6635); |
240 | assert_eq!(fnv1a(b"curds and \0" ), 0xd58c2c132109f00b); |
241 | assert_eq!(fnv1a(b"curds and \0" ), 0xe78baf81243f47d1); |
242 | assert_eq!(fnv1a(b"curds and w \0" ), 0xb0968f7096a2ee7c); |
243 | assert_eq!(fnv1a(b"curds and wh \0" ), 0xb425a84ff807855c); |
244 | assert_eq!(fnv1a(b"curds and whe \0" ), 0x23e4e9e2751b56f9); |
245 | assert_eq!(fnv1a(b"curds and whey \0" ), 0x1a0b4eccfe1396ea); |
246 | assert_eq!(fnv1a(b"curds and whey \n\0" ), 0x54abd453bb2c9004); |
247 | assert_eq!(fnv1a(b"hi" ), 0x08ba5f07b55ec3da); |
248 | assert_eq!(fnv1a(b"hi \0" ), 0x337354193006cb6e); |
249 | assert_eq!(fnv1a(b"hello" ), 0xa430d84680aabd0b); |
250 | assert_eq!(fnv1a(b"hello \0" ), 0xa9bc8acca21f39b1); |
251 | assert_eq!(fnv1a(b" \xff\x00\x00\x01" ), 0x6961196491cc682d); |
252 | assert_eq!(fnv1a(b" \x01\x00\x00\xff" ), 0xad2bb1774799dfe9); |
253 | assert_eq!(fnv1a(b" \xff\x00\x00\x02" ), 0x6961166491cc6314); |
254 | assert_eq!(fnv1a(b" \x02\x00\x00\xff" ), 0x8d1bb3904a3b1236); |
255 | assert_eq!(fnv1a(b" \xff\x00\x00\x03" ), 0x6961176491cc64c7); |
256 | assert_eq!(fnv1a(b" \x03\x00\x00\xff" ), 0xed205d87f40434c7); |
257 | assert_eq!(fnv1a(b" \xff\x00\x00\x04" ), 0x6961146491cc5fae); |
258 | assert_eq!(fnv1a(b" \x04\x00\x00\xff" ), 0xcd3baf5e44f8ad9c); |
259 | assert_eq!(fnv1a(b" \x40\x51\x4e\x44" ), 0xe3b36596127cd6d8); |
260 | assert_eq!(fnv1a(b" \x44\x4e\x51\x40" ), 0xf77f1072c8e8a646); |
261 | assert_eq!(fnv1a(b" \x40\x51\x4e\x4a" ), 0xe3b36396127cd372); |
262 | assert_eq!(fnv1a(b" \x4a\x4e\x51\x40" ), 0x6067dce9932ad458); |
263 | assert_eq!(fnv1a(b" \x40\x51\x4e\x54" ), 0xe3b37596127cf208); |
264 | assert_eq!(fnv1a(b" \x54\x4e\x51\x40" ), 0x4b7b10fa9fe83936); |
265 | assert_eq!(fnv1a(b"127.0.0.1" ), 0xaabafe7104d914be); |
266 | assert_eq!(fnv1a(b"127.0.0.1 \0" ), 0xf4d3180b3cde3eda); |
267 | assert_eq!(fnv1a(b"127.0.0.2" ), 0xaabafd7104d9130b); |
268 | assert_eq!(fnv1a(b"127.0.0.2 \0" ), 0xf4cfb20b3cdb5bb1); |
269 | assert_eq!(fnv1a(b"127.0.0.3" ), 0xaabafc7104d91158); |
270 | assert_eq!(fnv1a(b"127.0.0.3 \0" ), 0xf4cc4c0b3cd87888); |
271 | assert_eq!(fnv1a(b"64.81.78.68" ), 0xe729bac5d2a8d3a7); |
272 | assert_eq!(fnv1a(b"64.81.78.68 \0" ), 0x74bc0524f4dfa4c5); |
273 | assert_eq!(fnv1a(b"64.81.78.74" ), 0xe72630c5d2a5b352); |
274 | assert_eq!(fnv1a(b"64.81.78.74 \0" ), 0x6b983224ef8fb456); |
275 | assert_eq!(fnv1a(b"64.81.78.84" ), 0xe73042c5d2ae266d); |
276 | assert_eq!(fnv1a(b"64.81.78.84 \0" ), 0x8527e324fdeb4b37); |
277 | assert_eq!(fnv1a(b"feedface" ), 0x0a83c86fee952abc); |
278 | assert_eq!(fnv1a(b"feedface \0" ), 0x7318523267779d74); |
279 | assert_eq!(fnv1a(b"feedfacedaffdeed" ), 0x3e66d3d56b8caca1); |
280 | assert_eq!(fnv1a(b"feedfacedaffdeed \0" ), 0x956694a5c0095593); |
281 | assert_eq!(fnv1a(b"feedfacedeadbeef" ), 0xcac54572bb1a6fc8); |
282 | assert_eq!(fnv1a(b"feedfacedeadbeef \0" ), 0xa7a4c9f3edebf0d8); |
283 | assert_eq!(fnv1a(b"line 1 \nline 2 \nline 3" ), 0x7829851fac17b143); |
284 | assert_eq!(fnv1a(b"chongo <Landon Curt Noll> / \\../ \\" ), 0x2c8f4c9af81bcf06); |
285 | assert_eq!(fnv1a(b"chongo <Landon Curt Noll> / \\../ \\\0" ), 0xd34e31539740c732); |
286 | assert_eq!(fnv1a(b"chongo (Landon Curt Noll) / \\../ \\" ), 0x3605a2ac253d2db1); |
287 | assert_eq!(fnv1a(b"chongo (Landon Curt Noll) / \\../ \\\0" ), 0x08c11b8346f4a3c3); |
288 | assert_eq!(fnv1a(b"http://antwrp.gsfc.nasa.gov/apod/astropix.html" ), 0x6be396289ce8a6da); |
289 | assert_eq!(fnv1a(b"http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash" ), 0xd9b957fb7fe794c5); |
290 | assert_eq!(fnv1a(b"http://epod.usra.edu/" ), 0x05be33da04560a93); |
291 | assert_eq!(fnv1a(b"http://exoplanet.eu/" ), 0x0957f1577ba9747c); |
292 | assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/cam3/" ), 0xda2cc3acc24fba57); |
293 | assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/cams/HMcam/" ), 0x74136f185b29e7f0); |
294 | assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/kilauea/update/deformation.html" ), 0xb2f2b4590edb93b2); |
295 | assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/kilauea/update/images.html" ), 0xb3608fce8b86ae04); |
296 | assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/kilauea/update/maps.html" ), 0x4a3a865079359063); |
297 | assert_eq!(fnv1a(b"http://hvo.wr.usgs.gov/volcanowatch/current_issue.html" ), 0x5b3a7ef496880a50); |
298 | assert_eq!(fnv1a(b"http://neo.jpl.nasa.gov/risk/" ), 0x48fae3163854c23b); |
299 | assert_eq!(fnv1a(b"http://norvig.com/21-days.html" ), 0x07aaa640476e0b9a); |
300 | assert_eq!(fnv1a(b"http://primes.utm.edu/curios/home.php" ), 0x2f653656383a687d); |
301 | assert_eq!(fnv1a(b"http://slashdot.org/" ), 0xa1031f8e7599d79c); |
302 | assert_eq!(fnv1a(b"http://tux.wr.usgs.gov/Maps/155.25-19.5.html" ), 0xa31908178ff92477); |
303 | assert_eq!(fnv1a(b"http://volcano.wr.usgs.gov/kilaueastatus.php" ), 0x097edf3c14c3fb83); |
304 | assert_eq!(fnv1a(b"http://www.avo.alaska.edu/activity/Redoubt.php" ), 0xb51ca83feaa0971b); |
305 | assert_eq!(fnv1a(b"http://www.dilbert.com/fast/" ), 0xdd3c0d96d784f2e9); |
306 | assert_eq!(fnv1a(b"http://www.fourmilab.ch/gravitation/orbits/" ), 0x86cd26a9ea767d78); |
307 | assert_eq!(fnv1a(b"http://www.fpoa.net/" ), 0xe6b215ff54a30c18); |
308 | assert_eq!(fnv1a(b"http://www.ioccc.org/index.html" ), 0xec5b06a1c5531093); |
309 | assert_eq!(fnv1a(b"http://www.isthe.com/cgi-bin/number.cgi" ), 0x45665a929f9ec5e5); |
310 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/bio.html" ), 0x8c7609b4a9f10907); |
311 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/index.html" ), 0x89aac3a491f0d729); |
312 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/src/calc/lucas-calc" ), 0x32ce6b26e0f4a403); |
313 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/astro/venus2004.html" ), 0x614ab44e02b53e01); |
314 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/astro/vita.html" ), 0xfa6472eb6eef3290); |
315 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/comp/c/expert.html" ), 0x9e5d75eb1948eb6a); |
316 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/comp/calc/index.html" ), 0xb6d12ad4a8671852); |
317 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/comp/fnv/index.html" ), 0x88826f56eba07af1); |
318 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/number/howhigh.html" ), 0x44535bf2645bc0fd); |
319 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/number/number.html" ), 0x169388ffc21e3728); |
320 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/prime/mersenne.html" ), 0xf68aac9e396d8224); |
321 | assert_eq!(fnv1a(b"http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest" ), 0x8e87d7e7472b3883); |
322 | assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/corpspeak.cgi" ), 0x295c26caa8b423de); |
323 | assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/haiku.cgi" ), 0x322c814292e72176); |
324 | assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/rand-none.cgi" ), 0x8a06550eb8af7268); |
325 | assert_eq!(fnv1a(b"http://www.lavarnd.org/cgi-bin/randdist.cgi" ), 0xef86d60e661bcf71); |
326 | assert_eq!(fnv1a(b"http://www.lavarnd.org/index.html" ), 0x9e5426c87f30ee54); |
327 | assert_eq!(fnv1a(b"http://www.lavarnd.org/what/nist-test.html" ), 0xf1ea8aa826fd047e); |
328 | assert_eq!(fnv1a(b"http://www.macosxhints.com/" ), 0x0babaf9a642cb769); |
329 | assert_eq!(fnv1a(b"http://www.mellis.com/" ), 0x4b3341d4068d012e); |
330 | assert_eq!(fnv1a(b"http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm" ), 0xd15605cbc30a335c); |
331 | assert_eq!(fnv1a(b"http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm" ), 0x5b21060aed8412e5); |
332 | assert_eq!(fnv1a(b"http://www.paulnoll.com/" ), 0x45e2cda1ce6f4227); |
333 | assert_eq!(fnv1a(b"http://www.pepysdiary.com/" ), 0x50ae3745033ad7d4); |
334 | assert_eq!(fnv1a(b"http://www.sciencenews.org/index/home/activity/view" ), 0xaa4588ced46bf414); |
335 | assert_eq!(fnv1a(b"http://www.skyandtelescope.com/" ), 0xc1b0056c4a95467e); |
336 | assert_eq!(fnv1a(b"http://www.sput.nl/~rob/sirius.html" ), 0x56576a71de8b4089); |
337 | assert_eq!(fnv1a(b"http://www.systemexperts.com/" ), 0xbf20965fa6dc927e); |
338 | assert_eq!(fnv1a(b"http://www.tq-international.com/phpBB3/index.php" ), 0x569f8383c2040882); |
339 | assert_eq!(fnv1a(b"http://www.travelquesttours.com/index.htm" ), 0xe1e772fba08feca0); |
340 | assert_eq!(fnv1a(b"http://www.wunderground.com/global/stations/89606.html" ), 0x4ced94af97138ac4); |
341 | assert_eq!(fnv1a(&repeat_10(b"21701" )), 0xc4112ffb337a82fb); |
342 | assert_eq!(fnv1a(&repeat_10(b"M21701" )), 0xd64a4fd41de38b7d); |
343 | assert_eq!(fnv1a(&repeat_10(b"2^21701-1" )), 0x4cfc32329edebcbb); |
344 | assert_eq!(fnv1a(&repeat_10(b" \x54\xc5" )), 0x0803564445050395); |
345 | assert_eq!(fnv1a(&repeat_10(b" \xc5\x54" )), 0xaa1574ecf4642ffd); |
346 | assert_eq!(fnv1a(&repeat_10(b"23209" )), 0x694bc4e54cc315f9); |
347 | assert_eq!(fnv1a(&repeat_10(b"M23209" )), 0xa3d7cb273b011721); |
348 | assert_eq!(fnv1a(&repeat_10(b"2^23209-1" )), 0x577c2f8b6115bfa5); |
349 | assert_eq!(fnv1a(&repeat_10(b" \x5a\xa9" )), 0xb7ec8c1a769fb4c1); |
350 | assert_eq!(fnv1a(&repeat_10(b" \xa9\x5a" )), 0x5d5cfce63359ab19); |
351 | assert_eq!(fnv1a(&repeat_10(b"391581216093" )), 0x33b96c3cd65b5f71); |
352 | assert_eq!(fnv1a(&repeat_10(b"391581*2^216093-1" )), 0xd845097780602bb9); |
353 | assert_eq!(fnv1a(&repeat_10(b" \x05\xf9\x9d\x03\x4c\x81" )), 0x84d47645d02da3d5); |
354 | assert_eq!(fnv1a(&repeat_10(b"FEDCBA9876543210" )), 0x83544f33b58773a5); |
355 | assert_eq!(fnv1a(&repeat_10(b" \xfe\xdc\xba\x98\x76\x54\x32\x10" )), 0x9175cbb2160836c5); |
356 | assert_eq!(fnv1a(&repeat_10(b"EFCDAB8967452301" )), 0xc71b3bc175e72bc5); |
357 | assert_eq!(fnv1a(&repeat_10(b" \xef\xcd\xab\x89\x67\x45\x23\x01" )), 0x636806ac222ec985); |
358 | assert_eq!(fnv1a(&repeat_10(b"0123456789ABCDEF" )), 0xb6ef0e6950f52ed5); |
359 | assert_eq!(fnv1a(&repeat_10(b" \x01\x23\x45\x67\x89\xab\xcd\xef" )), 0xead3d8a0f3dfdaa5); |
360 | assert_eq!(fnv1a(&repeat_10(b"1032547698BADCFE" )), 0x922908fe9a861ba5); |
361 | assert_eq!(fnv1a(&repeat_10(b" \x10\x32\x54\x76\x98\xba\xdc\xfe" )), 0x6d4821de275fd5c5); |
362 | assert_eq!(fnv1a(&repeat_500(b" \x00" )), 0x1fe3fce62bd816b5); |
363 | assert_eq!(fnv1a(&repeat_500(b" \x07" )), 0xc23e9fccd6f70591); |
364 | assert_eq!(fnv1a(&repeat_500(b"~" )), 0xc1af12bdfe16b5b5); |
365 | assert_eq!(fnv1a(&repeat_500(b" \x7f" )), 0x39e9f18f2f85e221); |
366 | } |
367 | } |
368 | |