A
string salt = Crypto.GenerateSalt();
string saltAndPwd = String.Concat(originalPassword, salt);
string hashedPwd = Crypto.HashPassword(saltAndPwd);
B
string hashedPwd = Crypto.HashPassword(originalPassword);
May i know Method A and Method B, which is more secure ? or which is the correct approach ? with reflector, i found this is the hash password method in the core :
public static string HashPassword(string password)
{
if (password == null)
{
throw new ArgumentNullException("password");
}
return HashWithSalt(password, GenerateSaltInternal(0x10));
}
As the main purpose of using a salt is to defeat rainbow tables, adding additional salt to what
HashPasswordalready does doesn’t seem like it will gain you much benefit, and only incur additional overhead (as you have to store the salt you generate yourself.HashPasswordbuilds it into the returned value). For reference, this is whatHashPassworddoes:So, in short, what’s in the framework already is good enough for any reasonable definition of good enough.