You add the following method to compare a hashed password with a plaintext password:

private bool IsPasswordMatch(byte[] hashedPassword, string text)
{
byte[] bytes = Encoding.Unicode.GetBytes(text);
SHA1Managed SHhash = new SHA1Managed();

}
You need to add code to return true if the given password matches the hashed value.
Which code segment should you add?

 Posted by Rajkatie on 10/31/2012 | Category: ADO.NET Interview questions | Views: 1452 | Points: 40
Select from following answers:
  1. byte[] hashedPasswordToMatch = BitConverter.GetBytes(SHhash.GetHashCode()); return hashedPasswordToMatch.Length == hashedPassword.Length;
  2. byte[] hashedPasswordToMatch = SHhash.ComputeHash(bytes); return hashedPasswordToMatch.Length == hashedPassword.Length
  3. byte[] hashedPasswordToMatch = SHhash.ComputeHash(bytes);for (int i = 0; i < hashedPasswordToMatch.Length; i++) { if hashedPasswordToMatch[x] != hashedPasswordToMatch[x]) { return false; } return true;
  4. All Above

Show Correct Answer


Source: Measureup.com | | Alert Moderator 

Comments or Responses

Login to post response