「緑色の角」にこれに手を差し伸べるのに十分親切な人はいますか?現在、このプロジェクトに取り組んでいます。今ここでの考え方は、データベースからパスワードを取得し、ユーザーが入力したものと照合することです。保存されたパスワードはBcryptを使用して暗号化されます。私は今、いろいろな方法で試してみましたが、まだパスワードを一致させることができません。保存されたパスワード(Bcrypt)がどのユーザーの入力に一致することができません
コードの一部です。
// String command used from SQL, match AccountNo with Accountbox, Password with Passwordbox, from the Accounts dbo.
string a = string.Format("Select * from Accounts where AccountNo='{0}' and Password='{1}'", Accountbox ,Passwordbox);
SqlCommand ACCcheck = new SqlCommand(a, conn);
conn.Open();
SqlDataAdapter adapt1 = new SqlDataAdapter(ACCcheck);
DataSet data1 = new DataSet();
adapt1.Fill(data1);
SqlDataReader read = ACCcheck.ExecuteReader();
try
{
if (read.Read())
{
string salt = BCryptHelper.GenerateSalt(10);
string hash = BCryptHelper.HashPassword(Passwordbox, salt);
string OGpassword = read["Password"].ToString();
string givenPass = BCryptHelper.HashPassword(hash, Passwordbox);
if (givenPass.Equals(OGpassword))
{
//if (read.HasRows) // if input data valid, then proceed. if not then close conn and force retry.
//{
MessageBox.Show("WORDKING!");
conn.Close();
read.Close();
string q = string.Format("Select * from Transactions where AccountNo =" + Accountbox); // Fetch data from transaction table
SqlCommand cmd = new SqlCommand(q, conn); // SQL query, checks if what the user has written is a match with whats on the Db. Accountbox and Passwordbox are Inputbox I've used for this program.
ここにSQLエラーがあるのか、それとも壊れているBcryptの部分なのか分かりません。
援助に感謝します。