小编use*_*744的帖子

bcrypt.checkpw返回TypeError:必须在检查之前编码Unicode对象

我打电话bcrypt.checkpw检查未加密的密码匹配与存储在凭证数据库中的散列密码,但接收

TypeError:必须在检查之前对Unicode对象进行编码

我该如何解决这个问题?有什么建议吗?
我安装了python 2.7.6,和bcrypt 3.1.1

我有以下代码:

def check_password(password, hashed_password)
    if not bcrypt.checkpw(password, hashed_password):
        raise InvalidCredentials("403 Forbidden")
    else:
        return true
Run Code Online (Sandbox Code Playgroud)

并收到以下错误:

文件"/home/qt/virtualenv/lib/python2.7/site-packages/bcrypt/ init .py",第100行,在checkpw
引发TypeError("Unicoed-objects必须在检查之前编码")
TypeError:Unicode-objects必须在检查前进行编码

我调查了一下bcrypt/__init__.py,但我不确定为什么

def checkpw(password, hashed_password):    
    if (isinstance(password, six.text_type) or            
        isinstance(hashed_password, six.text_type)):        
    raise TypeError("Unicode-objects must be encoded before checking")
Run Code Online (Sandbox Code Playgroud)

python bcrypt

12
推荐指数
3
解决办法
1万
查看次数

标签 统计

bcrypt ×1

python ×1