def set_password(self, password, random=False): """ Encrypt the password and save it in the DB Return the password passed or the new password if randomed """ if random: password = utils.generate_random_string() self.update(password_hash=utils.encrypt_string(password)) return password
def test_encrypted_string(): pw = "hello world" e = utils.encrypt_string(pw) v = utils.verify_encrypted_string(pw, e) assert v is True