Last active
August 29, 2015 14:19
-
-
Save alertedsnake/bef343e7a5ccf4c8e3de to your computer and use it in GitHub Desktop.
Generate OpenLDAP SSHA password
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
import getpass | |
import hashlib | |
import os | |
from base64 import urlsafe_b64encode as encode | |
def make_secret(password): | |
salt=os.urandom(4) | |
sha = hashlib.sha1(password) | |
sha.update(salt) | |
digest_salt_b64 = '{}{}'.format(sha.digest(), salt).encode('base64').strip() | |
return '{{SSHA}}{}'.format(digest_salt_b64) | |
if __name__ == '__main__': | |
print(make_secret(getpass.getpass("password: "))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment