public static SecureData GenerateSaltedHexHash(SecureData value, SecureData salt) { var valueArray = value.Bytes; var saltArray = salt.Bytes; var algorithm = new SHA256Managed(); var valueWithSaltBytes = new byte[valueArray.Length + saltArray.Length]; for (var i = 0; i < valueArray.Length; i++) { valueWithSaltBytes[i] = valueArray[i]; } for (var i = 0; i < saltArray.Length; i++) { valueWithSaltBytes[valueArray.Length + i] = saltArray[i]; } return(new SecureData(ToHex(algorithm.ComputeHash(valueWithSaltBytes), true))); }
public static SecureData GenerateSaltedHash(SecureData value, SecureData salt) { var valueArray = value.Bytes; var saltArray = salt.Bytes; HashAlgorithm algorithm = new SHA512Managed(); var valueWithSaltBytes = new byte[value.Length + salt.Length]; for (var i = 0; i < value.Length; i++) { valueWithSaltBytes[i] = valueArray[i]; } for (var i = 0; i < salt.Length; i++) { valueWithSaltBytes[value.Length + i] = saltArray[i]; } var hashValue = Convert.ToBase64String(algorithm.ComputeHash(valueWithSaltBytes)); return(new SecureData(hashValue)); }