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

Random seed has only 8 bits of entropy #2

Open
Mart-Bogdan opened this issue Jan 15, 2024 · 0 comments · May be fixed by #4
Open

Random seed has only 8 bits of entropy #2

Mart-Bogdan opened this issue Jan 15, 2024 · 0 comments · May be fixed by #4

Comments

@Mart-Bogdan
Copy link

Current code is using CryproRandom to generate seed, but it uses only single byte

byte[] randomSeeds = new byte[1];
#if NET6_0_OR_GREATER
RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();
randomNumberGenerator.GetBytes(randomSeeds);
#else
// generating a random seed for the Random()
RNGCryptoServiceProvider rngCryptoServiceProvider = new RNGCryptoServiceProvider();
rngCryptoServiceProvider.GetBytes(randomSeeds);
#endif
// creating an instance of Random() using the random seed value
Random random = new Random(randomSeeds[0]);

This means that there are possible only 256 different outputs generated by this lib for same input parameters.

Need to take 4 bytes and convert them to int.

jshergal added a commit to jshergal/RandomString4Net that referenced this issue Sep 25, 2024
@jshergal jshergal linked a pull request Sep 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant