Created
April 25, 2014 08:37
-
-
Save hnnesv/11282253 to your computer and use it in GitHub Desktop.
Create a sql insert statement for adding a openhim webui user
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 hashlib | |
import random | |
import string | |
import sys | |
def generateSalt(): | |
s=string.lowercase+string.digits | |
return ''.join(random.sample(s,10)) | |
if __name__ == "__main__": | |
if len(sys.argv) < 3: | |
print "Generate a SQL insert for a username and password" | |
print "Usage: %s username password" % sys.argv[0] | |
else: | |
salt = generateSalt() | |
passw = hashlib.md5(salt + sys.argv[1] + sys.argv[2]).hexdigest() | |
print "insert into users(username, password, salt) values ('%s', '%s', '%s')" % (sys.argv[1], passw, salt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment