主题:
生成md5串
环境: winxp pro + sp2 + python2.5
备注: 请注意,凡是在源代码文件中使用了中文字符,请最好保存为utf-8格式
代码:
备注: 请注意,凡是在源代码文件中使用了中文字符,请最好保存为utf-8格式
代码:
python 代码
- # tmd5.py
- import md5
- import hashlib
- src = 'this is a test.'
- m1 = md5.new()
- m1.update(src)
- dest1 = m1.hexdigest()
- m2 = hashlib.md5()
- m2.update(src)
- dest2 = m2.hexdigest()
- print 'source string: ', src
- print 'destination string1: ', dest1
- print 'destination string2: ', dest2
测试:保存为文件,直接执行即可