Last active
August 29, 2015 13:56
-
-
Save AnimeshShaw/52f931e572171b6e4a56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import hashlib | |
""" | |
Encrypts given string | |
Method: md5, sha1, sha224, sha256, sha384, sha512 | |
Supports: Salts | |
How to use: encrypt('password', 'sha512', '04/16/2010') | |
""" | |
def encrypt(String, Method='md5', Salt=None): | |
if Method not in ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']: | |
print 'Unknown encryption' | |
else: | |
if Salt == None: | |
command = "print hashlib.%s('%s').hexdigest()" % (Method, String) | |
exec command | |
else: | |
command = "print hashlib.%s('%s' + '%s').hexdigest()" %(Method, String, Salt) | |
exec command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment