php - 密码验证;这种做法安全吗?

标签 php mysql html security

我有一个分类网站,每个人都可以在上面转换他们产品的广告。

对于每个分类,用户必须输入密码(以便他们可以随时删除分类)。

所以基本上,当有人想要删除分类时,他们点击分类,点击删除按钮,然后输入通行证。

我使用 MySql 作为数据库。

我基本上使用这段代码:

if ($pass==$row['poster_password'])

其中行[poster_password] 是从 MySql 中获取的...

你怎么看? 谢谢

最佳答案

看这个:Secure hash and salt for PHP passwords

在进入数据库的过程中对他们的密码进行哈希处理(可能加一些盐)。将他们的散列密码存储在数据库中(不是他们的实际密码)。然后从数据库中获取他们的散列密码并对他们输入的密码进行散列并比较散列密码。

一些蹩脚的伪代码:

password_hash = hash(password_cleartext)
# store password_hash in database

后来:

input_password_hash = hash(input_password_cleartext)
fetched_password_hash_from_db = fetch(db, password_hash)
if (input_password_hash == fetched_password_hash_from_db) {
    ... authenticated ...
}

要开始使用 php,请尝试:http://php.net/manual/en/function.sha1.php

关于php - 密码验证;这种做法安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2768017/

相关文章:

php - 在 laravel 中查找 future 7 天内过生日的客户

javascript - 两个 Onclick 函数,ajax/php 或 JS。首先调用什么?

html - 将元素宽度设置为 100% 可滚动宽度

HTML/CSS : show submenu next to parent MENU, 不是父项

php - 如何获取 YouTube 视频的所有评论

mysql - 如何在 RHEL 7.4 上安装 cloudstack

php - 删除当前日期和上周之间的记录 - 间隔 14 天

php - MYSQL PHP 将 ID 数组与表进行比较并按顺序返回新数组

c# - Html 编码导致 Chrome 中出现新行

php - PayumBundle 在后台捕获付款并不容易