代码如下:
#! /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(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)