I have the code working in .Net framework 4.5 but when i try to code the same in .Net framework 2.0, it gives compilation error
'System.Security.Cryptography.Rfc2898DeriveBytes': type used in a using statement must be implicitly convertible to System.IDisposable
How to fix it?
CODE
[ComVisible(true)]
public string HashPassword(string password)
{
byte[] salt;
byte[] subkey;
using (var deriveBytes = new Rfc2898DeriveBytes(password, SaltSize, PBKDF2IterCount))
{
salt = deriveBytes.Salt;
subkey = deriveBytes.GetBytes(PBKDF2SubkeyLength);
}
var outputBytes = new byte[1 + SaltSize + PBKDF2SubkeyLength];
//some more code goes here
return Convert.ToBase64String(outputBytes);
}
Taking inspiration from André's comment, it would appear that the Dispose method wasn't introduced until .NET 4: DeriveBytes.Dispose
(note: "Other Versions")
You could take a look at how the Dispose method is implemented in the current framework and consider adapating it to your project: Source Browser
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