]> thyrsus.com Git - comparator.git/commitdiff
Forward-port to new md5 interface.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 19 Oct 2010 07:32:45 +0000 (03:32 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 19 Oct 2010 07:32:45 +0000 (03:32 -0400)
hashgen.py

index efad28f6352c926ccbffe2de404b4cb5c23b407a..5c31f19cd3b74d6353a6e4b0ba726ae674f15394 100755 (executable)
@@ -1,9 +1,9 @@
 #!/bin/env python
-# Generate hash function mapping text bytes to an unsigned integral type, using
-# MD5 to generate the magic values.  Based on an algorithm suggested by
-# Ron Rivest.
+# Generate hash function mapping text bytes to an unsigned integral
+# type, using MD5 to generate the magic values.  Based on an algorithm
+# suggested by Ron Rivest.
 
-import sys, md5
+import sys, hashlib
 
 def tablegen(maxlen, width):
     print "static hashval_t magicbits[256][%d] = " % maxlen
@@ -13,7 +13,7 @@ def tablegen(maxlen, width):
         for j in range(maxlen):
             if j % 3 == 0:
                 sys.stdout.write('\n\t')
-            m = md5.new()
+            m = hashlib.md5()
             m.update(`i` + `j`)
             sys.stdout.write('0x' + m.hexdigest()[-(width*2):] + "ULL,")
         print "}, /* end char %02x */" % i