通过SQL验证用户输入的正确方法 [英] The correct method for validating user input via SQL

查看:135
本文介绍了通过SQL验证用户输入的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的一部分要求用户输入他们的密码到应用程序然后应用程序验证数据库中的表中的密码列我的问题是这是正确的sql查询来检索



part of my application requires the user to enter in their password to the application the application then validates against the password column in a table on a database my question is is this the correct sql query to retrieve that

SqlCommand cmd = new SqlCommand("Select Passwords: From Users Where Passwords:="UserInput.passwordbox", Connection");





数据库中的表(用户)中的密码列(密码:)(测试)



我尝试过:





the password column (Passwords:) in the table (Users) in a database (Test)

What I have tried:

SqlCommand cmd = new SqlCommand("Select Passwords: From Users Where Passwords:="UserInput.passwordbox", Connection");

推荐答案

整个想法都错了 - 请看我对这个问题的评论。

请阅读:加密哈希函数 - 维基百科,免费的百科全书 [ ^ ]。



始终记住,密码本身对用户而言比对一个特定密码保护的个人数据更有价值。无论用户的访问级别如何,都不应该知道用户的密码。



此外,理想情况下,使用基于密码的身份验证的真正敏感的网页应该通过使用HTTPS保护,而不仅仅是HTTP协议:

HTTPS - 维基百科,免费的百科全书 [ ^ ],

< a href =https://en.wikipedia.org/wiki/Transport_Layer_Security>传输层安全 - 维基百科,免费的百科全书 [ ^ ]。



-SA
The whole idea is wrong — please see my comment to the question.
Please read: Cryptographic hash function — Wikipedia, the free encyclopedia[^].

Always remember that the password itself can be more valuable to the user than the personal data protected by one particular password. No one should know the user's password, no matter what level of access a person might have.

Besides, ideally, the really sensitive Web pages using password-based authentication should be secured via the use of HTTPS, not just HTTP protocol:
HTTPS — Wikipedia, the free encyclopedia[^],
Transport Layer Security — Wikipedia, the free encyclopedia[^].

—SA


这篇关于通过SQL验证用户输入的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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