Created
November 24, 2014 17:39
-
-
Save meineerde/1ed655dca31fd904fbf7 to your computer and use it in GitHub Desktop.
mkpasswd 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
#!/usr/bin/env python | |
# Generate a new SHA512 shadow password hash from a given password | |
# Based on https://github.com/antoncohen/mksha | |
import getpass | |
import sys | |
# To install this library, use one of these: | |
# pip install passlib | |
# easy_install passlib | |
from passlib.hash import sha512_crypt | |
if __name__ == "__main__": | |
passwd = getpass.getpass('Password to hash: ') | |
passwd_repeat = getpass.getpass('Repeat: ') | |
if (passwd != passwd_repeat): | |
print "Passwords don't match!" | |
sys.exit(1) | |
hash = sha512_crypt.encrypt(passwd) | |
print hash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment