python 加密方式(MD5&sha&hashlib)
1.MD5加密
import md5
m = md5.new()
#或者m = md5.md5()
m.update('123456')
m.hexdigest()
#或者md5.md5('123456').hexdigest()
运行结果:
'e10adc3949ba59abbe56e057f20f883e'
2.sha加密
import sha
s = sha.new()
#或者s = sha.sha()
s.update('123456')
s.hexdigest()
运行结果:
'7c4a8d09ca3762af61e59520943dc26494f8941b'
3.hashlib加密
import hashlib
h1 = hashlib.md5('123456')
h1.hexdigest()
运行结果:
'e10adc3949ba59abbe56e057f20f883e'
h2 = hashlib.sha1('123456')
h1.hexdigest()
运行结果:
'7c4a8d09ca3762af61e59520943dc26494f8941b'
h3 = hashlib.sha224('123456')
h1.hexdigest()
运行结果:
'f8cdb04495ded47615258f9dc6a3f4707fd2405434fefc3cbf4ef4e6'
h4 = hashlib.sha256('123456')
h1.hexdigest()
运行结果:
'8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
h5 = hashlib.sha384('123456')
h1.hexdigest()
运行结果:
'0a989ebc4a77b56a6e2bb7b19d995d185ce44090c13e2984b7ecc6d446d4b61ea9991b76a4c2f04b1b4d244841449454'
h6 = hashlib.sha512('123456')
h1.hexdigest()
运行结果:
'ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346ec8c17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413'
posted on 2014-04-27 16:35 SpringStudio 阅读(3064) 评论(1) 编辑 收藏 举报