python中的SHA256加密中的数据类型问题
我正在制作一个数据库项目,其中我正在使用Python和MySQL。发生的事情是,我将用户密码加密并将其存储在SQL数据库中,作为VARCHAR数据类型。
但是,当我从数据库中回电时,它以字符串出现并显示以下错误:
这是函数:
def decrypt(password, hashed):
return pwd_context.verify(password, hashed)
在此中,使用sql从databse调用'hashed'变量,并返回为字符串
我应该怎么办?
编辑: 加密代码:
def encrypt(password):
password=str(password)
return pwd_context.hash(password)
I am making a database project in which I am using python and MySQL. What happens is I encrypt the user password and store it in the sql database as varchar datatype.
But when I call it back from the database, it comes as a string and shows the following error:
This is the function:
def decrypt(password, hashed):
return pwd_context.verify(password, hashed)
In this, the 'hashed' variable is called from databse using sql and returns as a string
What should I do?
EDIT:
Encryption Code:
def encrypt(password):
password=str(password)
return pwd_context.hash(password)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论