Take a look at this functions i've written to accomplish the task youre
describing:

from random import choice
from string import printable
from crypt import crypt as _crypt

def crypt(passwd, salt=None):
    if not salt:
        salt = ''.join([choice(printable) for i in xrange(2)])
    return _crypt(passwd, salt)

def isValidPassword(passwd, crypted):
    salt = crypted[:2]
    if crypt(passwd, salt) == crypted:
        return True
    else:
        return False

NOTE: this code just stores the crypted passsword in the db, does NOT
encrypt it while in transit.
Hope it helps,
Alberto

Jeremy Jones wrote:
> I'm trying to get identity working and am hitting a bit of a glitch.
> I've got a user stored in my database, associated with a group, and I
> can log in as him, but I've got the password in the clear in the
> database.

Reply via email to