使用 md5 加密

import hashlib

m = hashlib.md5()
m.update('hello world'.encode('utf-8'))      # 加密的字符串需要先编码成 utf-8
print(m.hexdigest())                         # 打印计算出字符串的MD5值

运行结果:
5eb63bbbe01eeed093cb22bb8f5acdc3

使用 sha256 加密

import hashlib

m = hashlib.sha256()
# print(m)

m.update('hello world'.encode('utf-8'))
print(m.hexdigest())

运行结果:
b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-04
  • 2021-10-22
  • 2021-06-20
  • 2021-07-26
  • 2021-09-25
  • 2022-01-20
  • 2021-08-29
相关资源
相似解决方案