According to the docs here, I should be able to create Rfc2898DeriveBytes with a custom hash algorithm (SHA256 in my case):
public Rfc2898DeriveBytes (byte[] password, byte[] salt, int iterations, System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
I have created a .NET Standard 2.0 class library with the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
My Class
private static byte[] Pbkdf2(string data)
{
// ...
using(var pbkdf2 = new Rfc2898DeriveBytes(null, null, 50000, HashAlgorithmName.SHA256))
{
return pbkdf2.GetBytes(32);
}
}
I get the following error:
'Rfc2898DeriveBytes' does not contain a constructor that takes 4 arguments
Why can I not add a hash algorithm to the constructor of Rfc2898DeriveBytes?
The link you posted is for .NET Framework, not .NET Standard. The documentation for.NET Standard is here. In .NET Standard there is no constructor with 4 parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With