将密码与随机盐进行比较
我有 ac# 应用程序,我正在尝试使用 php 和 mysql 编写一个基本的登录表单来存储密码。
我使用 SHA512 + 随机盐来存储密码,因此目前我正在对密码执行此操作。
哈希(密码+随机Salt)+随机Salt;
因此,盐会附加到哈希值中,然后发送到服务器并存储。
现在我的问题是比较某人尝试登录的时间。用户不知道盐,而且我不想将纯文本密码发送到服务器,所以我有点卡住了。
我应该加密密码并将其发送到服务器,让服务器向用户发送盐还是有更好的方法来实现这一点?
我只是想确保创建帐户密码的任何人都具有一定的安全性。
提前致谢
I have a c# app and I'm trying to write a basic login form using php and mysql to store passwords.
I'm using SHA512 + random salt to store passwords so currently I'm doing this for the passwords.
hash(password+randomSalt)+randomSalt;
So the salt is appended to the hash then sent to the server and stored.
Now my problem is comparing when someone tries login. The user doesn't know the salt, and I don't want to send the plain text password to the server so I'm a little stuck.
Should I be encrypting the password and sending it to the server, having the server send the user the salt or is there a better way to implement this?
I just want to make sure anyone who makes an account password is moderately secure.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,您应该将散列密码和随机盐值存储在数据库中。
当用户进行身份验证时,他或她的用户名和密码将被发送到服务器(最好通过 SSL 安全连接)。从那里,您使用用户名从数据库中检索盐值和散列密码以进行比较。
最重要的是,您永远不应该存储纯文本密码或通过不安全的连接发送它们。
有关详细信息,请参阅密码哈希、加盐和哈希值存储信息。
In general, you should store the hashed passwords and random salt values in the database.
When a user authenticates, his or her username and password are sent to the server (preferably, over an SSL secured connection). Form there, you use the username to retrieve the salt value and hashed password from the database to do your comparison with.
Bottom line, you should never store plain-text passwords or send them over an unsecured connection.
See Password hashing, salt and storage of hashed values for more info.
这几乎是不可能的。正如 Derek 所说,正确的做法是获取 SSL 证书并通过该证书发送纯文本密码。
加盐是为了防止被盗的密码数据库泄露每个人的密码。但如果哈希步骤在客户端完成,则数据库中的值就是通过网络发送的确切字符串。
如果您确实无法使用 SSL,http://en.wikipedia.org/wiki/Challenge- response_authentication#Cryptographic_techniques 描述了一种避免发送密码(或哈希值,几乎相同)的方法。
It's pretty much impossible. Like Derek said, the right thing is get an SSL cert and send plain text passwords over that.
Salting is to protect a stolen password database from revealing everyones password. But if the hash step is done on the client, the value in the database is the exact string that is sent over the network.
If you really cannot use SSL, http://en.wikipedia.org/wiki/Challenge-response_authentication#Cryptographic_techniques describes a way to avoid sending the password (or the hash, which is almost the same).