当前位置: 编程技术>python
python基础教程之python消息摘要算法使用示例
来源: 互联网 发布时间:2014-09-04
本文导语: 代码如下:#! /usr/bin/python''' File : testHash.py Author : Mike'''import hashlibsrc = raw_input("Input string : ")funcNameList = ["MD5","SHA1","SHA224","SHA256","SHA384","SHA512"]funcMap = {"MD5" : lambda cnt : hashlib.md5(cn...
代码如下:
#! /usr/bin/python
'''
File : testHash.py
Author : Mike
'''
import hashlib
src = raw_input("Input string : ")
funcNameList = ["MD5","SHA1","SHA224","SHA256","SHA384","SHA512"]
funcMap = {
"MD5" : lambda cnt : hashlib.md5(cnt).hexdigest(),
"SHA1" : lambda cnt : hashlib.sha1(cnt).hexdigest(),
"SHA224" : lambda cnt : hashlib.sha224(cnt).hexdigest(),
"SHA256" : lambda cnt : hashlib.sha256(cnt).hexdigest(),
"SHA384" : lambda cnt : hashlib.sha384(cnt).hexdigest(),
"SHA512" : lambda cnt : hashlib.sha512(cnt).hexdigest()
}
for funcName in funcNameList :
print funcName,"t:t",funcMap[funcName](src)