Skip to content

Instantly share code, notes, and snippets.

@Neilblaze
Created July 28, 2020 21:39
Show Gist options
  • Save Neilblaze/377a5c24072c7e41686104e119709275 to your computer and use it in GitHub Desktop.
Save Neilblaze/377a5c24072c7e41686104e119709275 to your computer and use it in GitHub Desktop.
Encrpytx_TEXT => Hash a string using a multitude of hashing Algorithms
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment