【发布时间】:2022-04-12 01:40:43
【问题描述】:
如果要执行以下操作:
def hashmdfive(filename):
"""Generate the md5 checksum."""
hasher = hashlib.md5()
with open(filename, "rb") as afile:
buf = afile.read()
hasher.update(buf)
return hasher.hexdigest()
- 制作一个包含一些内容的文件(例如
test.txt)。 - 通过运行上面的 hashmdive 创建文件的哈希。
- 提交并推送到远程 git 存储库
- 删除本地文件。
- 从远程获取
test.txt - 通过运行上面的 hashmdive 创建文件的新哈希。
哈希值不同。有谁知道为什么会这样?
【问题讨论】:
-
你看过行尾吗?他们一致吗?一些管道将
CR LF自动格式化为LF -
就像一个注释,MD5 现在对于几乎所有用途都完全没用。请改用 SHA-256 或 BLAKE2b。