Created
November 10, 2017 01:01
-
-
Save msghens/63142812a9ba41c36b278600e3b4b22b 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
| #!/usr/bin/env python | |
| import hashlib | |
| import secrets | |
| import sys | |
| """ | |
| This method generates the sha1 hex of the password+salt. | |
| """ | |
| def gen_digested_password(pw,salt=secrets.token_hex(4).upper()): | |
| print (salt.encode()) | |
| print (len(salt.encode())) | |
| print (sys.getsizeof(salt.encode())) | |
| return (hashlib.sha1(pw.encode() + salt.encode()).hexdigest() + ':' + salt).upper() | |
| """ | |
| This method decodes a ssha-encoded password string, returning the | |
| digest and salt | |
| """ | |
| def decode_ssha_password(ssha_password): | |
| decoded = base64.b64decode(ssha_password.replace("{SSHA}","")) | |
| digest = decoded[0:40] | |
| salt = decoded[40:] | |
| return digest,salt | |
| print(gen_digested_password('helloworld','ZZDK05NS')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment