import hashlib as hb
data = hb.md5('abc'.encode('utf-8')) #开始加密
print data.hexdigest() #显示加密结果
#以下是特殊用法,比如要加密的字符串太长,可以分多次加密,即update(a) + update(bc) = update(abc)
data_1 = data.copy()
data.update('a'.encode('utf-8'))
data.update('bc'.encode('utf-8'))
print data.hexdigest()
data_1.update('abc'.encode('utf-8'))
print data_1.hexdigest()
#以下是运行结果
Python2.7 hashlib模块学习
最新推荐文章于 2024-05-08 15:38:44 发布