def setPassword(self, password, hashed=False): """Sets the user's password.""" if hashed or self.hashed: self.hashed = True self.password = utils.saltHash(password) else: self.password = password
def checkPassword(self, password): """Checks the user's password.""" if password is None: return False if self.hashed: (salt, _) = self.password.split('|') return (self.password == utils.saltHash(password, salt=salt)) else: return (self.password == password)
def testSaltHash(self): s = utils.saltHash('jemfinch') (salt, hash) = s.split('|') self.assertEqual(utils.saltHash('jemfinch', salt=salt), s)