public static bool VerifyPassword(string user, string password) { string PASS = Connectimimedb.GetSalt(user, false); // Console.WriteLine(PASS); string testhash = GjeneroSalt.GjeneroSHA256Hashin(password, PASS); // Console.WriteLine(testhash); string dbHash = Connectimimedb.GetSalt(user, true); if (dbHash == testhash) { return(true); } else { return(false); } }
public static void InsertStudent(string name) { Regex obj = new Regex("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{6,}$"); //Console.Write("First Name : "); // string fname = Console.ReadLine(); string Password = ""; bool passinput = true; while (passinput) { Console.Write("Password : "******""; if (obj.IsMatch(password1)) { Console.Write("Re type Password :"******"Passwordi duhet te permbaje karakteret e speecifikaura"); passinput = true; } bool pass = false; if ((Password != password1) & !(Password == "")) { pass = true; passinput = false; } while (pass & !passinput) { Console.WriteLine("Paswordat nuk perputhen"); Console.Write("Password : "******"Re type Password :"******"passwordi duhet te permbaje karakteret e specifikuara"); passinput = true; pass = true; } } } String salt = GjeneroSalt.KrijoSalt(10); string hashFjalkalimi; hashFjalkalimi = GjeneroSalt.GjeneroSHA256Hashin(Password, salt); con = new OleDbConnection(); con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Lenovo\\Desktop\\Detyra1_DS-Gr-6-master\\ds\\bin\\Debug\\netcoreapp3.0\\appDB.accdb"; cmd = new OleDbCommand(); cmd.Connection = con; cmd.CommandText = "INSERT INTO USERS (Emri,Passwordi,Salt,Hash) VALUES ('" + name + "','" + Password + "','" + salt + "','" + hashFjalkalimi + "')"; // cmd.CommandText = "INSERT INTO Users (Name,Password) VALUES ('" + fname + "','" + Password+ "'); //www.csharp-console-example.com con.Open(); int sonuc = cmd.ExecuteNonQuery(); con.Close(); if (sonuc > 0) { Console.WriteLine("Inserted"); } else { Console.WriteLine("Three are errors. The record was not inserted."); } }