Python 3:文件和数字资产/文件/哈希
外观
pip install pillow
pip install requests
%pip install pillow
%pip install requests
import hashlib
def hash_file_sha1(
location_of_file: str
) -> str:
value: str | None = None
hash_algorithm = hashlib.sha1()
with open(
location_of_file,
'rb'
) as file:
chunk = 0
while chunk != b'':
chunk = file.read(1024)
hash_algorithm.update(chunk)
value = str(
hash_algorithm.hexdigest()
)
return value