标签:python print port hashlib模块 on() object date update class
# 导入hashlib模块 import hashlib # 获取MD5对象 # 不加盐操作 # md5 = hashlib.md5() # 加盐操作 md5 = hashlib.md5(‘wenwe1i‘.encode("utf8")) # 获取需要加密的字段 md5.update(‘how to use md5 in python hashlib?‘.encode("utf8")) print(md5.hexdigest())
class Md5(object): def __init__(self, salt, content): self.salt = salt self.content = content def encryption(self): import hashlib md5 = hashlib.md5(self.salt.encode("utf8")) md5.update(self.content.encode("utf8")) ret = md5.hexdigest() return ret ret = Md5(‘wenwe1i‘, ‘how to use md5 in python hashlib?‘) ret.encryption()
标签:python print port hashlib模块 on() object date update class
原文地址:https://www.cnblogs.com/Rivend/p/11785192.html