Dear all,
I am trying verify the createdpasswordHash with u.username. Do i need to create a new method for this or can I just amend the exsiting 'validate' method.
private static string CreateSalt() { RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buff = new byte[32]; rng.GetBytes(buff); return Convert.ToBase64String(buff); } private static string CreatePasswordHash(string pwd, string salt) { string saltAndPwd = String.Concat(pwd, salt); string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile( saltAndPwd, "sha1"); return hashedPwd; } public api_login Validate2(string userName, string Password) { // Find a user that matches that username and password (this will only validate if both match) return db.api_login.FirstOrDefault(u => u.username == userName && u.password == Password); }
Any help will be most appreciated. Many thanks.