密码哈希算法
我对哈希密码不太了解,但我想知道。我想知道以下算法对于没有信用卡信息或类似信息的普通网站有多好,我也想知道如何改进它。 算法是:
hash('sha512', crypt(hash('whirlpool', $password.$username), base64_encode(md5(strlen($password)))))
I don't know much about hashing passwords, but I'd like to know. I'd like to know how good the following algorithm is for a normal site without credit card information or something like that, and I also want to know how to improve it.
The algorithm is:
hash('sha512', crypt(hash('whirlpool', $password.$username), base64_encode(md5(strlen($password)))))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
不要混合超过一种哈希值,每种哈希值都经过优化,可以单独发挥最佳作用。
根据您使用该哈希的内容,将 $password 放入其中也是一个非常糟糕的主意。如果它存储在用户的计算机上,即存储在 cookie 中。你不希望它在那里。
如果将哈希存储在数据库中,您还可以通过在使用哈希算法之前添加动态随机字符串来使其更好。然后将为用户每次访问生成一个新的哈希值。
Don't mix more than one hash, each one is optimized to work best by itself.
Depending on what you are using that hash for it's also a very bad idea to put $password in it. If it is being stored on the user's computer that is, like in a cookie. You don't want that in there.
If you store the hash in a database you can also make it better by adding a dynamic random string before using the hashing algorithm. Then a new hash will be generated for the user each visit.
我强烈建议使用众所周知的、经过测试的、经过审查的哈希/加密函数,而不是任何本土的算法。
I would highly recommend using a well-known, tested, vetted hash/crypt function over any home-grown algorithm.
这是我创建的一个类,用于存储我集成的 api 的 ID/密码组合。每个用户都可以拥有自己独特的凭据。我不建议在不兼容 PCI 的计算机上存储任何信用卡数据。
这正是我的课程,但你们有一些缺失的部分,所以我已经对它们进行了评论。请注意,该向量是唯一的(将其视为哈希),我将其与加密数据一起存储在数据库中。
密钥位于公共目录之外,这涉及到保护您的盒子的另一个主题。
Here is a class that I created to store a id/password combos for an api I integrate with. Each user can have their own unique credentials. I do not advise storing any credit card data on a non PCI compliant computer.
This is my exact class but you have some missing pieces so I have commented those. Please note that the vector is unique (Think of it as a hash) and I store that in the database along with the encrypted data.
The key is out of the public directory which goes to another topic of securing your box.
如果你想要强大的东西。你必须
- 永远不要保存密码,而是保存哈希值(不需要太多)以避免数据库黑客使用密码。
If you want something strong. you have to
- never save the password but a hash (don't need so much) to avoid db hack use of password.
尝试我编写的这个(非常易于使用)类,其中包括自动算法检测,以获得您的服务器支持的最安全的算法:
try this (very easy to use) class I wrote which includes automatic algorithm detection to get the most secure algorithm that your server supports: http://netentwicklung.wordpress.com/2012/06/17/87/