def check_password(self, raw_password): """ Returns a boolean of whether the raw_password was correct. """ salt, hsh = self.pw_hash.split(u'$') return hsh == get_hexdigest(salt, raw_password)
def set_password(self, raw_password): """Set a new sha1 generated password hash""" salt = u'%05x' % random.getrandbits(20) hsh = get_hexdigest(salt, raw_password) self.pw_hash = u'%s$%s' % (salt, hsh)