We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d848660 + b1d784d commit 0cbf493Copy full SHA for 0cbf493
webArchiver.py
@@ -95,10 +95,22 @@ def forcedir(file_path):
95
96
97
def hasher(filein, hname, blocksize):
98
- htype = getattr(hashlib, hname, "N/A")
99
- if htype == "N/A":
100
- print("wrong hash type")
101
- exit(1)
+ htype = {
+ "blake2s": lambda: hashlib.blake2s(),
+ "sha384": lambda: hashlib.sha384(),
+ "sha512": lambda: hashlib.sha512(),
102
+ "sha3_256": lambda: hashlib.sha3_256(),
103
+ "sha256": lambda: hashlib.sha256(),
104
+ "md5": lambda: hashlib.md5(),
105
+ "sha3_512": lambda: hashlib.sha3_512(),
106
+ "sha3_224": lambda: hashlib.sha3_224(),
107
+ "shake_128": lambda: hashlib.shake_128(),
108
+ "shake_256": lambda: hashlib.shake_256(),
109
+ "sha1": lambda: hashlib.sha1(),
110
+ "blake2b": lambda: hashlib.blake2b(),
111
+ "sha224": lambda: hashlib.sha224(),
112
+ "sha3_384": lambda: hashlib.sha3_384(),
113
+ }.get(hname, lambda: (print("wrong hash type"), exit(1)))()
114
with open(filein, 'rb') as fi:
115
while True:
116
data = fi.read(blocksize)
0 commit comments