-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_hasher.py
More file actions
31 lines (27 loc) · 918 Bytes
/
password_hasher.py
File metadata and controls
31 lines (27 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
from util import *
hash_method = None
password = None
from_cmd = False
if len(sys.argv) == 3:
from_cmd = True
hash_method = sys.argv[1]
password = sys.argv[2]
if hash_method is None:
print("Supported hash method: MD5 SHA1 SHA256 SHA512 Argon2")
while hash_method is None:
hash_method = input("Please select a hash method: [Argon2]")
hash_method = hash_method.lower()
if hash_method == "":
hash_method = "argon2"
elif hash_method not in ["md5", "sha1", "sha256", "sha512", "argon2"]:
print("Hash method not found")
hash_method = None
if password is None:
password = input("Please input a password:\n")
if not from_cmd:
print("Hash result:")
if hash_method in ["md5", "sha1", "sha256", "sha512"]:
print(calculate_hash(hash_method, password))
elif hash_method == "argon2":
print(argon2_hash(password))