Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the built-in CSPRNG GetInt32 #663

Merged

Conversation

vcsjones
Copy link
Contributor

.NET Core 3.0+ have this capability built-in, so use that instead of rolling it.

@@ -36,27 +36,7 @@ public class NumericUserCodeGenerator : IUserCodeGenerator
/// <returns></returns>
public Task<string> GenerateAsync()
{
var next = Next(100000000, 999999999);
var next = RandomNumberGenerator.GetInt32(100000000, 1000000000);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one built in to .NET has an exclusive upper bound, while the previous one was inclusive, hence the upper bound of 1_000_000_000.

@brockallen
Copy link
Member

brockallen commented Jan 20, 2022

Yo, it's @vcsjones -- howdy sir! Thanks for visiting our repo :)

@leastprivilege leastprivilege added this to the 6.1.0 milestone Jan 24, 2022
@leastprivilege leastprivilege added the enhancement New feature or request label Jan 24, 2022
@brockallen
Copy link
Member

LGTM

@leastprivilege leastprivilege merged commit f1d2be7 into DuendeSoftware:main Jan 24, 2022
@leastprivilege leastprivilege added internal and removed enhancement New feature or request labels Jan 24, 2022
@vcsjones vcsjones deleted the use-runtime-random-int32 branch January 24, 2022 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants