Last active
December 10, 2023 14:48
-
-
Save alshell7/981c2e9c4b82b675117b9fa063e65d65 to your computer and use it in GitHub Desktop.
Convert given string to SHA1 hash by hexadecimal digest in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sha1Hash(toHash): | |
try: | |
messageDigest = hashlib.sha1() | |
stringM = str(toHash) | |
byteM = bytes(stringM, encoding='utf') | |
messageDigest.update(byteM) | |
return messageDigest.hexdigest() | |
except TypeError: | |
raise "String to hash was not compatible" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment