I have a method to create a hashed password.
However it crashes at salt.CopyTo(pwd, 0);
Says that the target byte[] is too small.
How do I solve the problem?
public static byte[] CreateHashedPassword(string password, byte[] salt)
{
SHA1 sha1 = SHA1.Create();
byte[] pwd = CustomHelpers.StringToByteArray(password);
salt.CopyTo(pwd, 0);
sha1.ComputeHash(pwd);
return pwd;
}
You need to create a longer byte array to contain both the salt and the password: