-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_to_hash.py
36 lines (30 loc) · 1.11 KB
/
text_to_hash.py
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
#!/usr/bin/env python3
import hashlib
import argparse
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')
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)