python hashlib模块

'''
hashlib模块提供了很多加密的算法
'''

import hashlib

def hashlib_encode():
salt = '321321'
content = "admin"
md5 = hashlib.md5(bytes(salt,encoding='utf8'))
md5.update(bytes(content,encoding='utf-8'))
# d8823982474b60c7bdc2f4ee87b1cf2b
# md5 = hashlib.md5()
# md5.update(bytes(salt+content,encoding='utf8'))
# d8823982474b60c7bdc2f4ee87b1cf2b
result = md5.hexdigest()
print(result)
if __name__ == '__main__':
hashlib_encode()
pass
原文地址:https://www.cnblogs.com/lides/p/11123211.html