python中的SHA256加密中的数据类型问题

发布于 2025-02-12 01:16:49 字数 621 浏览 0 评论 0原文

我正在制作一个数据库项目,其中我正在使用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:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文