In my application I have a class that hashes passwords and generates salts. For some reason every hash seems to always end with a double equals sign (==).
Am I doing something wrong? Are these hashes not secure?
The application is in c# and asp.net and the code to generate the salts and hashes is as follows...
public class PasswordService : IPasswordService
{
private static RandomNumberGenerator random = RandomNumberGenerator.Create();
public string HashPassword(string salt, string password)
{
Rfc2898DeriveBytes hasher = new Rfc2898DeriveBytes(password, Convert.FromBase64String(salt), 10000);
byte[] hash = hasher.GetBytes(64);
return Convert.ToBase64String(hash);
}
public bool VerifyPasswordHash(string salt, string password, string hash)
{
return HashPassword(salt, password) == hash;
}
public string GenerateSalt()
{
int max_length = 32;
byte[] salt = new byte[max_length];
random.GetBytes(salt);
return Convert.ToBase64String(salt);
}
}
Thank you!