使用python计算md5
使用python计算md5
#!/usr/bin/env python3
import os
import hashlib
# Use hashlib module
file = open("foo", "rb")
content = file.read()
file.close()
result = hashlib.md5()
result.update(content)
md5sum = result.hexdigest()
print(md5sum)
# Use OS command
result = os.popen("md5sum foo").readline()
md5sum = result.split()[0]
print(md5sum)