Home >Backend Development >Python Tutorial >python基础教程之python消息摘要算法使用示例

python基础教程之python消息摘要算法使用示例

WBOY
WBOYOriginal
2016-06-16 08:45:241261browse

复制代码 代码如下:

#! /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)


python基础教程之python消息摘要算法使用示例
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn