summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-06-29 00:17:01 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-06-29 00:17:01 (GMT)
commit5f6b4a53c243f2e9fc84553ae562ffdcd57bc99a (patch)
tree51fe3bdf37bec1374a95376ff95df98d0967ca2d /Demo
parent26eb9d0b47e1bf4645119f2394f3c467b8fa5fb4 (diff)
downloadcpython-5f6b4a53c243f2e9fc84553ae562ffdcd57bc99a.zip
cpython-5f6b4a53c243f2e9fc84553ae562ffdcd57bc99a.tar.gz
cpython-5f6b4a53c243f2e9fc84553ae562ffdcd57bc99a.tar.bz2
Merged revisions 82351 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82351 | brian.curtin | 2010-06-28 19:14:28 -0500 (Mon, 28 Jun 2010) | 3 lines Update md5driver.py for 3.x. Changed an import, replaced md5.new() with md5(), and added an encode where needed. ........
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/md5test/md5driver.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Demo/md5test/md5driver.py b/Demo/md5test/md5driver.py
index ea30fd8..7df3e75 100755
--- 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)