Looking to store usernames and passwords in a database, and am wondering what the safest way to do so is. I know I have to use a salt somewhere, but am not sure how to gene
Here is a simpler way (taken from effbot), provided passwords with a length greater than 8 will not be a problem*:
import crypt
import random, string
def getsalt(chars = string.letters + string.digits):
# generate a random 2-character 'salt'
return random.choice(chars) + random.choice(chars)
for generate the password :
crypt.crypt("password", getsalt())
*: A password with a length greater than 8 is stripped from the right down to 8 chars long