【发布时间】:2015-11-19 14:09:52
【问题描述】:
我从 Nuget 为 Visual Studio 2015 安装了 PBKDF2 包。
我使用This resource 对我的密码字段进行哈希处理。
public static string CreateHash(string password)
{
// Generate a random salt
RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();
byte[] salt = new byte[SALT_BYTE_SIZE];
csprng.GetBytes(salt);
// Hash the password and encode the parameters
byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
return PBKDF2_ITERATIONS + ":" +
Convert.ToBase64String(salt) + ":" +
Convert.ToBase64String(hash);
}
但我明白了:
编译器错误消息:CS0118:“System.Security.Cryptography.PBKDF2”是“类型”,但用作“变量”
这是用于行中的 PBKDF2 调用 -> byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
那么我如何将它作为变量而不是方法应用并仍然传递这些参数?
另外,为什么我首先会收到该错误? source 看起来是一个非常好的来源,并且在很多地方都有引用,包括有关 stackoverflow 的问题。
【问题讨论】:
标签: visual-studio hash cryptography visual-studio-2015 pbkdf2