# 导入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()

 

相关文章:

  • 2021-06-02
  • 2021-06-19
  • 2022-12-23
  • 2021-10-03
  • 2021-05-04
猜你喜欢
  • 2022-02-25
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案