Standard: RNGCryptoServiceProvider missing from .net standard 1.6

Created on 18 Jun 2017  路  5Comments  路  Source: dotnet/standard

Hello,

Is RNGCryptoServiceProvider missing or has the name been changed? I

I use RNGCryptoServiceProvider to create random salts and ore security items. So I really need it.

Thank you,
Thomas

Most helpful comment

RandomNumberGenerator.Create() is the preferred call over new RNGCryptoServiceProvider(), in both .NET Core and .NET Framework. It produces a RNGCryptoServiceProvider on .NET Framework (by default), and on .NET Core produces an opaque type which is based on BCryptGenRandom (Windows), or OpenSSL's random number generator (!Windows) (and in .NET Core 2.0 is based on CCRandomGenerateBytes for macOS).

https://stackoverflow.com/questions/38632735/rngcryptoserviceprovider-in-net-core/38644970#38644970

All 5 comments

According to aspisof.net, RNGCryptoServiceProvider is not available in .Net Standard 1.x. It will exist in .Net Standard 2.0 though.

Is there a reason why you can't use RandomNumberGenerator instead, which exists in .Net Standard 1.3+?

RandomNumberGenerator.Create() is the preferred call over new RNGCryptoServiceProvider(), in both .NET Core and .NET Framework. It produces a RNGCryptoServiceProvider on .NET Framework (by default), and on .NET Core produces an opaque type which is based on BCryptGenRandom (Windows), or OpenSSL's random number generator (!Windows) (and in .NET Core 2.0 is based on CCRandomGenerateBytes for macOS).

https://stackoverflow.com/questions/38632735/rngcryptoserviceprovider-in-net-core/38644970#38644970

@bartonjs

The documentation for RandomNumberGenerator says:

Application code does not directly use this class. This abstract class is provided as the base class for all cryptographic random number generators.

For an implementation of a cryptographic random number generator, use the derived class RNGCryptoServiceProvider.

Are you saying this does not reflect the preferred practice even on .Net Framework and should be updated?

@svick Yep. Good catch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lmagyar picture lmagyar  路  4Comments

shuohus picture shuohus  路  5Comments

spottedmahn picture spottedmahn  路  5Comments

rathnagiri picture rathnagiri  路  3Comments

ghost picture ghost  路  4Comments