def hashtest(k, m):
h = k
for ch in m: h = gfmul(h ^ ord(ch), k)
- print(' 0x%08x "%s" 0x%08x;' % (k, m, h))
+ print('')
+ print('k = 0x%08x' % k)
+ print('m = "%s"' % m)
+ print('h = 0x%08x' % h)
print('''\
-### Test vectors for universal hashing
-### [generated]
+;;; -*-conf-*- Test vectors for universal hashing
+;;; [generated]
-hash {''')
+[unihash]''')
for k, m in [(0x00000000, 'anything you like'),
(0x12345678, 'an exaple test string'),
(0xb8a171f0, 'The quick brown fox jumps over the lazy dog.'),
+ (0xcc825ed5, 'Jackdaws love my big sphinx of quartz.'),
+ (0x16e98e46, 'Waltz, bad nymph, for quick jigs vex!'),
(0x2940521b, 'A man, a plan, a canal: Panama!')]:
hashtest(k, m)
for i in xrange(48):
hashtest(k, "If we don't succeed, we run the risk of failure.")
k = gfmul(k, m)
-
-print('}')