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