Skip to content

Instantly share code, notes, and snippets.

@jfparis
Created August 5, 2013 00:28
Show Gist options
  • Save jfparis/6152683 to your computer and use it in GitHub Desktop.
Save jfparis/6152683 to your computer and use it in GitHub Desktop.
generate NGINX salted SHA1 password dumps
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