【发布时间】:2012-05-29 02:05:51
【问题描述】:
我有一个使用加盐哈希加密密码的类。
但如果我想将 null 传递给类,则会收到以下错误:Cannot implicitly convert type string to byte[]
这是课程代码:
public class MyHash
{
public static string ComputeHash(string plainText,
string hashAlgorithm, byte[] saltBytes)
{
Hash Code
}
}
当我使用该类时,我收到错误:“无法将类型字符串隐式转换为字节 []”
//Encrypt Password
byte[] NoHash = null;
byte[] encds = MyHash.ComputeHash(Password, "SHA256", NoHash);
【问题讨论】:
-
strings 是否应该可以转换为byte[]?