I am using .net 3.5. The problem here is that I cannot get the passwords to match. I tried using the ComputeHash method for both, but it generates a different hash. Since they are now arrays of different sizes. (Obviously, they are based on one line). What have I done wrong? ("password" is byte [] param by user input)
object dataPassword = database.ExecuteScalar("GetUserPassword", new object[] {userName}); if(dataPassword != null && !(dataPassword is DBNull)) { SHA1Managed hashProvider = new SHA1Managed(); byte[] hashedPassword = (byte[])dataPassword; byte[] hash = hashProvider.ComputeHash(password); result = hashedPassword.Equals(hash); }
Jonasb
source share