X-Git-Url: https://git.distorted.org.uk/~mdw/mLib/blobdiff_plain/7cf5c72a6d353ed5a7e340562c11e54c21c85e5e..37342632a8bb95fe68ece90d18b8b69263edb83b:/hash/t/unihash-testgen.py diff --git a/hash/t/unihash-testgen.py b/hash/t/unihash-testgen.py index 2fe8982..1fde21f 100644 --- a/hash/t/unihash-testgen.py +++ b/hash/t/unihash-testgen.py @@ -3,6 +3,9 @@ ### ### Generate test vectors for universal hashing. +import sys as SYS +if SYS.version_info >= (3,): xrange = range + MOD = 0x104c11db7 def gfmul(x, y): @@ -17,13 +20,13 @@ def gfmul(x, y): 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(' 0x%08x "%s" 0x%08x;' % (k, m, h)) -print '''\ +print('''\ ### Test vectors for universal hashing ### [generated] -hash {''' +hash {''') for k, m in [(0x00000000, 'anything you like'), (0x12345678, 'an exaple test string'), @@ -36,4 +39,4 @@ for i in xrange(48): hashtest(k, "If we don't succeed, we run the risk of failure.") k = gfmul(k, m) -print '}' +print('}')