18 lines
271 B
Python
18 lines
271 B
Python
|
import hashlib
|
||
|
|
||
|
|
||
|
BUF_SZ = 4096
|
||
|
|
||
|
|
||
|
def hash_file_sha512(filename):
|
||
|
res = hashlib.sha512()
|
||
|
with open(filename, 'rb') as f:
|
||
|
data = f.read(BUF_SZ)
|
||
|
while data:
|
||
|
res.update(data)
|
||
|
data = f.read(BUF_SZ)
|
||
|
return res.hexdigest()
|
||
|
|
||
|
|
||
|
|