diff --git a/aspnetcore/security/data-protection/consumer-apis/password-hashing/samples/passwordhasher.cs b/aspnetcore/security/data-protection/consumer-apis/password-hashing/samples/passwordhasher.cs index c3540a39e0c5..9ce280d7289c 100644 --- a/aspnetcore/security/data-protection/consumer-apis/password-hashing/samples/passwordhasher.cs +++ b/aspnetcore/security/data-protection/consumer-apis/password-hashing/samples/passwordhasher.cs @@ -11,10 +11,8 @@ public static void Main(string[] args) // generate a 128-bit salt using a cryptographically strong random sequence of nonzero values byte[] salt = new byte[128 / 8]; - using (var rngCsp = new RNGCryptoServiceProvider()) - { - rngCsp.GetNonZeroBytes(salt); - } + RandomNumberGenerator random = RandomNumberGenerator.Create(); + random.GetNonZeroBytes(salt); Console.WriteLine($"Salt: {Convert.ToBase64String(salt)}"); // derive a 256-bit subkey (use HMACSHA256 with 100,000 iterations)