You've already forked vk26-onlinehasherapp
init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#!/bin/python
|
||||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
CONFFILE = Path("config.txt")
|
||||
INPUT_DIR = Path("input")
|
||||
OUTPUT_DIR = Path("output")
|
||||
|
||||
HASHMODE = "md5"
|
||||
|
||||
with open(CONFFILE) as f:
|
||||
hash_type = f.read().strip()
|
||||
|
||||
if hash_type not in ["md5", "sha256"]:
|
||||
print("Invalid hash type in config")
|
||||
exit(1)
|
||||
|
||||
HASHMODE = hash_type
|
||||
|
||||
for file in tuple(INPUT_DIR.iterdir()):
|
||||
with open(file, "rb") as f:
|
||||
content = f.read()
|
||||
|
||||
if HASHMODE == "md5":
|
||||
hash = hashlib.md5(content).hexdigest()
|
||||
elif HASHMODE == "sha256":
|
||||
hash = hashlib.sha256(content).hexdigest()
|
||||
else:
|
||||
hash = ""
|
||||
|
||||
dest = OUTPUT_DIR / (file.name + ".md5")
|
||||
with open(dest, "w") as f:
|
||||
f.write(hash)
|
||||
Reference in New Issue
Block a user