Created
August 5, 2013 00:28
-
-
Save jfparis/6152683 to your computer and use it in GitHub Desktop.
generate NGINX salted SHA1 password dumps
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 subprocess | |
import hashlib | |
import base64 | |
username=raw_input("username:") | |
password =raw_input("password:") | |
# use openssl to generate securly a salt | |
pipe = subprocess.Popen("openssl rand -base64 3", shell=True, bufsize=100, stdout=subprocess.PIPE).stdout | |
salt = pipe.readline().rstrip() | |
pipe.close() | |
m = hashlib.sha1() | |
m.update(password+salt) | |
hash = m.digest()+salt | |
print "copy paste the following line to your password file" | |
print username+":{SSHA}"+base64.b64encode(hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment