标签:min b16 hash import port mina encode utf-8 imp
>>> import hashlib
>>> m=hashlib.md5()
>>> print(m) #<md5 HASH object @ 0x000001ED5CB71468>
>>> m.update(‘admin‘.encode(‘utf-8‘))
>>> print(m.hexdigest()) #21232f297a57a5a743894a0e4a801fc3
>>> m.update(‘aaaa‘.encode(‘utf-8‘)) #在前者基础上再进行加密这时加密的不是 aaaa 是 adminaaaa
>>> print(m.hexdigest()) #19799a0f30118efd90732c2a4b56be7c
>>> s=hashlib.sha256()
>>> print(s) #<sha256 HASH object @ 0x000002B193CF1468>
>>> s.update(‘admin‘.encode(‘utf-8‘))
>>> print(s.hexdigest()) #8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
>>> s.update(‘aaaa‘.encode(‘utf-8‘)) #在前者基础上再进行加密这时加密的不是 aaaa 是 adminaaaa
>>> print(s.hexdigest()) #8d36408d8f07e97c803f6b18a507b4688362b9680cfc29a080179f4d1a6525aa
标签:min b16 hash import port mina encode utf-8 imp
原文地址:http://blog.51cto.com/13562606/2060605