数据比较 [英] Data comparing

查看:157
本文介绍了数据比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表格,其中可以比较存储在数据库中的用户ID和密码.
请为我提供解决方案.

I have created a form in which how can compare user id and password which is stored in database.
Please provide me solution.

推荐答案

您似乎不太可能需要帮助来比较数据.由于您所需要做的就是使用== operator.

示例:

It seems quite improbable that you need help comparing the data. Since all you need to do is use the == operator.

Example:

if(passwordEntered == GetPasswordFromDB(usernameEntered))
{
   // you are now authenticated
   
}



注意:请参见OriginalGriff的答案,其中他描述了如何避免以明文形式存储和比较密码.



Note: See OriginalGriff''s answer where he describes how you can avoid storing and comparing the password in clear text.


使用密码的SHA哈希值并将其与数据库存储的值进行比较.这样一来,密码不会随时保持清除状态,也不会被窃取.在生成SHA代码之前,将用户名/用户ID包含在密码字符串中也是一个好主意,以防止使用相同密码的两个用户具有相同的SHA代码.
用户ID可以以明文形式存储.
Use a SHA hash of the password and compare that with the database stored value. That way, the password is not held in clear at any time and cannot be stolen. It is also a good idea to include the username/userid in the password string before generating the SHA code to prevent two users with teh same password having identical SHA codes.
The userid can be stored in clear.


这篇关于数据比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆