Created
February 3, 2015 18:30
-
-
Save jfrost/26a489527de00a0b14e4 to your computer and use it in GitHub Desktop.
How to make a sha512sum for use in /etc/shadow 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/python | |
import crypt | |
import random | |
import string | |
def getsalt(mysalt = "", chars = string.letters + string.digits): | |
# generate a random 16-character 'salt' | |
for i in range(16): | |
mysalt = mysalt + random.choice(chars) | |
return mysalt | |
salt="$6$" + getsalt() | |
cleartextpassword = raw_input('New password: ') | |
print crypt.crypt(cleartextpassword, salt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment