Skip to content

Instantly share code, notes, and snippets.

@nikolak
Created August 18, 2013 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikolak/6264096 to your computer and use it in GitHub Desktop.
Save nikolak/6264096 to your computer and use it in GitHub Desktop.
import hashlib
valid_types=[ 'md5', 'sha1', 'ripemd160', 'sha224', 'sha256', 'sha384', 'sha512']
hash_type=None
while hash_type!="exit":
hash_type=raw_input("Enter hash type -- valid are: {}\n>>>".format(
', '.join(valid_types))).lower()
if hash_type in valid_types:
hashed=hashlib.new(hash_type)
hashed.update(raw_input("'Enter your string\n>>>"))
print hashed.hexdigest()
elif hash_type=="exit":
print "Bye!"
else:
print "Invalid input only {} is allowed".format(', '.join(valid_types))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment