diff --git a/src/DataProtection/Cryptography.KeyDerivation/src/PBKDF2/NetCorePbkdf2Provider.cs b/src/DataProtection/Cryptography.KeyDerivation/src/PBKDF2/NetCorePbkdf2Provider.cs index d6bd494b1c9c..35d130c2ad5d 100644 --- a/src/DataProtection/Cryptography.KeyDerivation/src/PBKDF2/NetCorePbkdf2Provider.cs +++ b/src/DataProtection/Cryptography.KeyDerivation/src/PBKDF2/NetCorePbkdf2Provider.cs @@ -54,11 +54,7 @@ private static byte[] DeriveKeyImpl(string password, byte[] salt, KeyDerivationP throw new ArgumentOutOfRangeException(); } - var passwordBytes = Encoding.UTF8.GetBytes(password); - using (var rfc = new Rfc2898DeriveBytes(passwordBytes, salt, iterationCount, algorithmName)) - { - return rfc.GetBytes(numBytesRequested); - } + return Rfc2898DeriveBytes.Pbkdf2(Encoding.UTF8.GetBytes(password), salt, iterationCount, algorithmName, numBytesRequested); } } }