Commit dca07528 authored by echel0n's avatar echel0n

Fixed issues with md5 checksum hasher to be compatible with python 3.5+

parent 4cdfcb08
......@@ -30,11 +30,14 @@ checksum_file = prog_dir.joinpath('checksums.md5')
def md5(filename):
with open(filename, "rb") as f:
file_hash = hashlib.md5()
while chunk := f.read(8192):
file_hash.update(chunk)
return file_hash.hexdigest()
blocksize = 8192
hasher = hashlib.md5()
with open(filename, 'rb') as afile:
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.hexdigest()
with open(checksum_file, "wb") as fp:
......
......@@ -21,7 +21,6 @@
import hashlib
import os
from pathlib import Path
main_dir = Path(__file__).parent
......@@ -30,11 +29,14 @@ checksum_file = prog_dir.joinpath('checksums.md5')
def md5(filename):
with open(filename, "rb") as f:
file_hash = hashlib.md5()
while chunk := f.read(8192):
file_hash.update(chunk)
return file_hash.hexdigest()
blocksize = 8192
hasher = hashlib.md5()
with open(filename, 'rb') as afile:
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.hexdigest()
with open(checksum_file, "rb") as fp:
......
......@@ -1744,11 +1744,14 @@ def strip_accents(name):
def md5_file_hash(filename):
with open(filename, "rb") as f:
file_hash = hashlib.md5()
while chunk := f.read(8192):
file_hash.update(chunk)
return file_hash.hexdigest()
blocksize = 8192
hasher = hashlib.md5()
with open(filename, 'rb') as afile:
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.hexdigest()
def get_extension(filename):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment