diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-06-29 00:14:28 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-06-29 00:14:28 (GMT) |
commit | 3778db7b513f3e32cd3fafc25c17c77e29797634 (patch) | |
tree | ceeae04571dbfcd56ea5619e9da5ad32d7634ff5 /Demo | |
parent | 3d1bfbf9a60b995771593e9c4323da29f44a5ec7 (diff) | |
download | cpython-3778db7b513f3e32cd3fafc25c17c77e29797634.zip cpython-3778db7b513f3e32cd3fafc25c17c77e29797634.tar.gz cpython-3778db7b513f3e32cd3fafc25c17c77e29797634.tar.bz2 |
Update md5driver.py for 3.x.
Changed an import, replaced md5.new() with md5(), and added an encode where needed.
Diffstat (limited to 'Demo')
-rw-r--r-- | Demo/md5test/md5driver.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Demo/md5test/md5driver.py b/Demo/md5test/md5driver.py index ea30fd8..7df3e75 100644 --- a/Demo/md5test/md5driver.py +++ b/Demo/md5test/md5driver.py @@ -1,11 +1,10 @@ +from hashlib import md5 import string -import md5 from sys import argv def MDPrint(str): outstr = '' - for i in str: - o = ord(i) + for o in str: outstr = (outstr + string.hexdigits[(o >> 4) & 0xF] + string.hexdigits[o & 0xF]) @@ -42,7 +41,7 @@ def MDTimeTrial(): print('MD5 time trial. Processing', TEST_BYTES, 'characters...') t1 = time() - mdContext = md5.new() + mdContext = md5() for i in range(TEST_BLOCKS): mdContext.update(data) @@ -57,13 +56,13 @@ def MDTimeTrial(): def MDString(str): - MDPrint(md5.new(str).digest()) + MDPrint(md5(str.encode("utf-8")).digest()) print('"' + str + '"') def MDFile(filename): f = open(filename, 'rb') - mdContext = md5.new() + mdContext = md5() while 1: data = f.read(1024) @@ -78,7 +77,7 @@ def MDFile(filename): import sys def MDFilter(): - mdContext = md5.new() + mdContext = md5() while 1: data = sys.stdin.read(16) |