-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathencrypt_text.py
More file actions
38 lines (31 loc) · 1.21 KB
/
encrypt_text.py
File metadata and controls
38 lines (31 loc) · 1.21 KB
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
32
33
34
35
36
37
38
# A Python Script which can hash a string using a multitude of Hashing Algorithms like SHA256, SHA512 and more
import hashlib
import argparse
import sys
def main(text, hashType):
encoder = text.encode("utf_8")
myHash = ""
if hashType.lower() == "md5":
myHash = hashlib.md5(encoder).hexdigest()
elif hashType.lower() == "sha1":
myHash = hashlib.sha1(encoder).hexdigest()
elif hashType.lower() == "sha224":
myHash = hashlib.sha224(encoder).hexdigest()
elif hashType.lower() == "sha256":
myHash = hashlib.sha256(encoder).hexdigest()
elif hashType.lower() == "sha384":
myHash = hashlib.sha384(encoder).hexdigest()
elif hashType.lower() == "sha512":
myHash = hashlib.sha512(encoder).hexdigest()
else:
print("[!] The script does not support this hash type")
sys.exit(0)
print("Your hash is: ", myHash)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert text to hash")
parser.add_argument("-t", "--text", dest="text", required=True)
parser.add_argument("-T", "--Type", dest="type", required=True)
args = parser.parse_args()
txt = args.text
hType = args.type
main(txt, hType)