You can change the random number generator by using the API or by changing
the *.config file. To set it by using the API, you need to change the
RandomNumberGenerator property of the
RandomNumberGeneratorFactory. By the property Instance of the
RandomNumberGeneratorFactory class, you get access to the
factory. Here you need to set the property RandomNumberGenerator
to a valid value. By default, the values "cryptographic" and "pseudo-random"
are possible. It is important that you change this property before you create
the password generator.
using CAM.PasswordGeneratorLibrary;
...
RandomNumberGeneratorFactory.Instance.RandomNumberGenerator = "cryptographic";
PasswordGenerator pwdGen =
new RandomPasswordGenerator(PasswordOptions.AllCharacters);
Console.WriteLine(pwdGen.Generate(8));It is also possible to configure the random number generator by changing the *.config file. For this you need to assign a valid value to the "RandomNumberGenerator" property of the "PasswordGeneratorDefaults" element, that is a child element of the "CAM.PasswordGeneratorLibrary" element. Here you can use the same values that you can use with the API. After this, it isn't necessary to change the value with the API.
<CAM.PasswordGeneratorLibrary>
<PasswordGeneratorDefaults PasswordGenerator="RandomPasswordGenerator"
RandomNumberGenerator="cryptographic" />
</CAM.PasswordGeneratorLibrary>