The Admin Application - Common pitfalls
Creating new users
*Note: This is no longer a problem in the Django development version, as of .*
One FAQ about the admin app is how to create new users. In particular how to set the password. It has been decided (and mooted on the lists) that the password field will only accept password hashes rather than plain text password. The problem is how one goes about generating these hashes. The following script will generate passwords on the command line. Run it with: python <scriptname> <password> and you'll get the correct output to paste into the admin app. IMPORTANT SECURITY NOTE: The password will turn up as plain text in your shell history, so take appropriate measures: change permissions, get an administrator you can trust or tweak the script not to use the command line.
import hashlib, random, sys try: raw_password = sys.argv except IndexError: print "Usage: %s password" % (sys.argv, ) sys.exit() algo = 'sha1' salt = hashlib.sha1(str(random.random())).hexdigest()[:5] hsh = hashlib.sha1(salt+raw_password).hexdigest() print "%s$%s$%s" % (algo, salt, hsh)