使用python求字符串或文件的MD5 五月 21st, 2008

#以下可在python3000运行。

#字符串md5,用你的字符串代替’字符串’中的内容。

import hashlib

md5=hashlib.md5(‘字符串’.encode(‘utf-8′)).hexdigest()

print(md5)

#求文件md5

import hashlib

#文件位置中的路径,请用双反斜杠,

如’D:\\abc\\www\\b.msi’ file='[文件位置]’

md5file=open(file,’rb’)

md5=hashlib.md5(md5file.read()).hexdigest()

md5file.close()

print(md5)

相关文章:

  • 2022-01-07
  • 2021-06-04
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-03-09
  • 2021-06-02
  • 2021-07-24
相关资源
相似解决方案