Python 字符串转MD5:

def getStrAsMD5(parmStr):
    #1、参数必须是utf8
    #2、python3所有字符都是unicode形式,已经不存在unicode关键字
    #3、python3 str 实质上就是unicode
    if isinstance(parmStr,str):
        # 如果是unicode先转utf-8
        parmStr=parmStr.encode("utf-8")
    m = hashlib.md5()
    m.update(parmStr)
    return m.hexdigest()

 

相关文章:

  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-02-11
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2021-07-24
  • 2021-07-13
相关资源
相似解决方案