From 136a04546af0202aaeff864467417f3a7669b253 Mon Sep 17 00:00:00 2001 From: gitdev <63194733+gitdev-bash@users.noreply.github.com> Date: Tue, 26 Jan 2021 15:22:23 +0100 Subject: [PATCH 1/2] Update webArchiver.py --- webArchiver.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/webArchiver.py b/webArchiver.py index 7672810..9790f89 100644 --- a/webArchiver.py +++ b/webArchiver.py @@ -95,22 +95,10 @@ def forcedir(file_path): def hasher(filein, hname, blocksize): - htype = { - "blake2s": lambda: hashlib.blake2s(), - "sha384": lambda: hashlib.sha384(), - "sha512": lambda: hashlib.sha512(), - "sha3_256": lambda: hashlib.sha3_256(), - "sha256": lambda: hashlib.sha256(), - "md5": lambda: hashlib.md5(), - "sha3_512": lambda: hashlib.sha3_512(), - "sha3_224": lambda: hashlib.sha3_224(), - "shake_128": lambda: hashlib.shake_128(), - "shake_256": lambda: hashlib.shake_256(), - "sha1": lambda: hashlib.sha1(), - "blake2b": lambda: hashlib.blake2b(), - "sha224": lambda: hashlib.sha224(), - "sha3_384": lambda: hashlib.sha3_384(), - }.get(hname, lambda: (print("wrong hash type"), exit(1)))() + htype = getattr(hashlib, hname, "N/A") + if htype == "N/A": + print("wrong hash type") + exit(1) with open(filein, 'rb') as fi: while True: data = fi.read(blocksize) From 7949c1bf14627d64aad7274fedc84ce50e33f4f4 Mon Sep 17 00:00:00 2001 From: gitdev <63194733+gitdev-bash@users.noreply.github.com> Date: Tue, 26 Jan 2021 15:36:34 +0100 Subject: [PATCH 2/2] Update webArchiver.py --- webArchiver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webArchiver.py b/webArchiver.py index 9790f89..7d59cc5 100644 --- a/webArchiver.py +++ b/webArchiver.py @@ -95,8 +95,8 @@ def forcedir(file_path): def hasher(filein, hname, blocksize): - htype = getattr(hashlib, hname, "N/A") - if htype == "N/A": + htype = getattr(hashlib, hname, print)() + if htype is None: print("wrong hash type") exit(1) with open(filein, 'rb') as fi: