I have a class that encrypts a password with a salted hash.
But If I want to pass a null to the class I get the following error: Cannot implicitly convert type string to byte[]
Here is the class code:
public class MyHash
{
public static string ComputeHash(string plainText,
string hashAlgorithm, byte[] saltBytes)
{
Hash Code
}
}
When I use the class I get the error: “Cannot implicitly convert type string to byte[]”
//Encrypt Password
byte[] NoHash = null;
byte[] encds = MyHash.ComputeHash(Password, "SHA256", NoHash);
The return type of your
ComputeHashfunction is astring. You try to assign the result of your function toencds, which isbyte[]. The compiler points this discrepancy out to you, because there is no implicit conversion fromstringtobyte[].