如何将图片转换为 Sha256 哈希 Python



是否可以将图片输入到hashlib的sha256功能中,并让它使用Python吐出一个哈希?

也许这有帮助?链接

您必须导入哈希库,打开文件,然后计算哈希。

import hashlib
filename = "Filepath to image file.png"
with open(filename,"rb") as f:
bytes = f.read() # read entire file as bytes
readable_hash = hashlib.sha256(bytes).hexdigest();
print(readable_hash)

最新更新