Staging
v0.5.1
https://github.com/python/cpython
Revision 2e1beeac2e61e5b93afd89fc7798599dbf1618d2 authored by Guido van Rossum on 11 June 1996, 18:40:02 UTC, committed by Guido van Rossum on 11 June 1996, 18:40:02 UTC
hacks for Windows and DOS here already :-( ).
1 parent 8bac546
Raw File
Tip revision: 2e1beeac2e61e5b93afd89fc7798599dbf1618d2 authored by Guido van Rossum on 11 June 1996, 18:40:02 UTC
Add a hack for Solaris threads (why not, there are zillions of
Tip revision: 2e1beea
test_md5.py
# Testing md5 module

import string
from md5 import md5

def hexstr(s):
	h = string.hexdigits
	r = ''
	for c in s:
		i = ord(c)
		r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
	return r

def md5test(s):
	return 'MD5 ("' + s + '") = ' + hexstr(md5(s).digest())

print 'MD5 test suite:'
print md5test('')
print md5test('a')
print md5test('abc')
print md5test('message digest')
print md5test('abcdefghijklmnopqrstuvwxyz')
print md5test('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
print md5test('12345678901234567890123456789012345678901234567890123456789012345678901234567890')
back to top