Python bcrypt postgres编码/解码问题?

问题描述 投票:0回答:1

我有一个使用bcrypt的简单Flask应用。我已经在这个简单易用的库上花费了几个小时来解决编码问题。登录方法调用doDecideHashedPassword方法,如果凭据匹配,则应返回true或false。

也请注意以下内容

  1. 我使用postgres,目前我的密码字段设置为varchar(500)
  2. 我将散列密码转换为str以将其准确地存储在数据库中。

[当我从数据库中请求哈希密码,并将其通过下面的doDecodeHashedPassword传递时,我得到了无效的salt。它接受来自表单的电子邮件和密码。

def doDecodeHashedPassword(self, email, password):
        getpwd = ClientUser.query.filter_by(email=email).one()
        getpwd = getpwd.password
        getpwd = getpwd.encode()
        password = password
        check_user_integrity = bcrypt.checkpw(password,getpwd)
        if check_user_integrity:
            return (check_user_integrity)
        else:
            return False

为什么我得到无效的盐错误。

python-3.x bcrypt
1个回答
0
投票

我需要做的就是确保密码的解码格式存储在数据库中。这使我发疯了一段时间,但现在可以挽救了。

© www.soinside.com 2019 - 2024. All rights reserved.