MySQL和Python:在密码的前两个字符之后加盐

发布于 2025-01-28 17:42:44 字数 505 浏览 4 评论 0原文

我在MySQL和Python工作。我有一个存储用户登录信息并希望使此安全的表格。在密码的前两个字符之后,如何添加盐?然后,我要使用SHA256进行哈希。

该表看起来像这样:

用户名密码
测试testing123ABC09

我使用这样的表格制作了表,如果您可以在这里实现某些东西,我很乐意重做它。

CREATE TABLE `user` (
  `username` varchar(20) NOT NULL,
  `password` varchar(100) NOT NULL,
  `salt` varchar(100) DEFAULT NULL
);

稍后,我将使用Python不使用并检索密码。

I am working in MYSQL and Python. I have a table that stores users login information and want to make this secure. How do I add the salt after the first two characters of the password? I am then going to hash it using sha256.

The table looks like this:

usernamepasswordsalt
testtesting123abc09

I made the table using like this, bit if there is something you can implement here I am happy to redo it.

CREATE TABLE `user` (
  `username` varchar(20) NOT NULL,
  `password` varchar(100) NOT NULL,
  `salt` varchar(100) DEFAULT NULL
);

Later I am going to use python to unhash and retrieve the password.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵强ㄟ 2025-02-04 17:42:44

我发现通过Python进行此操作更容易。我使用密码并使用Hashlib插入盐。

I found out that it is easier to do this thru python. I hash the password and insert the salt using hashlib.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文