这种密码存储方式安全吗?
我只是在想,使用从密码本身创建的盐来创建密码哈希是否可以安全使用。这是 php 中的一个例子:
<?php
$pass = $_GET['pass'];
$salt = hash('whirlpool', $pass);
$pass = md5(hash('whirlpool', $salt.$pass));
echo $pass;
?>
这有意义吗?
问候。
I was just thinking if creating a password hash by using a salt created from the password himself is safe to use. Here an example in php:
<?php
$pass = $_GET['pass'];
$salt = hash('whirlpool', $pass);
$pass = md5(hash('whirlpool', $salt.$pass));
echo $pass;
?>
Does this make sense ?
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
盐的目的是使每个人的密码都是唯一的。因此,在这种情况下,当给出相同的原始密码时,仅对他们的密码进行散列并将其添加为盐仍然会使 2 个用户的最终散列密码相等。最好为每个用户提供一个随机盐并将其存储在数据库中的密码旁边。
The point of a salt is to make everyone's password unique. So in this case just hashing their password and adding it as a salt would still make 2 user's final hashed password equal when the same original password is given. Better to give each user a random salt and store that right beside their password in the db.
无需对密码进行哈希、重新哈希和重新哈希。
使用具有良好哈希码算法的盐是一件好事,但您需要强制您的用户发送具有最小大小和字母数字字符的强密码
注释:
It's no necessary to hash and re hash and re re hash the password.
Use a salt with a good hashcode algorithm is a good thing, but you need to force yours users to send a strongly password with a minimum of size and with alphanumeric characters
notes:
我这样做
I do it like this
您可以保护您的密码和盐。
使用 SHA256 或更高版本(2012 年),未来几年它必须更高。
为每个用户使用不同的盐。
使用计算出的盐。
创建一个 16 到 32 字节的 Salt 并将其存储在数据库中,称为“DBSalt”。
创建任何旧算法来操纵盐,但仅将算法保留在代码中。即使是像 DBSalt + 1 这样简单的东西也是有用的,因为如果有人获取了您的数据库,他们实际上并没有正确的盐,因为正确的盐是计算出来的。
按如下方式计算您的密码:
CreateHash(saltAlgorithm(dbSalt),password);
您可以通过以不同方式操作 DBSalt 的算法列表来增加安全性。每次用户更改密码时,您也会对 DBSalt 使用不同的计算
您可以通过将这些算法存储在
Web 服务器位于您的系统外部,因此如果您的数据库和代码都获得
被黑了,他们仍然没有你的盐。
“您可以通过...提高安全性”的评论层出不穷。请记住,每次增加安全性时,都会增加复杂性、成本等...
如何有效地对数据库中存储为哈希值的密码加盐
You can protect both your password and your salt.
Use SHA256 or higher (2012) and in years to come it must be higher.
Use a different salt for every user.
Use a calculated salt.
Create a 16 to 32 byte Salt and store it in the database, called 'DBSalt'.
Create any old algorithm to manipulate the salt but keep the algorithm only in code. Even something as simple as DBSalt + 1 is useful because if someone gets your database, they don't actually have the correct salt because the correct salt is calculated.
Calculate your password as follows:
CreateHash(saltAlgorithm(dbSalt), password);
You can add security by having a list of algorithms that manipulate the DBSalt in different ways. Every time a user changes their password you also use a different calculation against the DBSalt
You can add more security by having these algorithms be stored on
web servers external to your system so if your DB and code both get
hacked, they still don't have your salt.
There is no end to the "You can increase security by..." comments. Just remember, every time you add security, you add complexity, cost, etc...
How to effectively salt a password stored as a hash in a database