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

Question: replicating exact functionality of Math.random() #38

Open
gc opened this issue Mar 9, 2020 · 2 comments · May be fixed by #65
Open

Question: replicating exact functionality of Math.random() #38

gc opened this issue Mar 9, 2020 · 2 comments · May be fixed by #65

Comments

@gc
Copy link

gc commented Mar 9, 2020

Kind of 2 quick questions:

  1. I want to replicate the exact output of Math.random(), is this correct? real(0, 1, false)(engine);
  2. I'm replacing Math.random() with the above because I want the output to be unpredictable, as I've seen that its possible, given a sample of outputs of Math.random(), a user can determine what the next outputs will be. I was wondering if you could confirm, for my sanity, that using this library will prevent that? I'm using nodeCrypto as an engine.
@rawr51919
Copy link

Math.random() certainly isn't perfect and an RNG engine like this already tries to make this a reality anyway. @ckknight any input?

@rawr51919
Copy link

rawr51919 commented Sep 19, 2023

Kind of 2 quick questions:

1. I want to replicate the exact output of Math.random(), is this correct? `real(0, 1, false)(engine);`

2. I'm replacing Math.random() with the above because I want the output to be unpredictable, as I've seen that its possible, given a sample of outputs of Math.random(), a user can determine what the next outputs will be. I was wondering if you could confirm, for my sanity, that using this library will prevent that? I'm using `nodeCrypto` as an engine.

@gc I had a think on that and yeah, to a degree that will help with that problem, but no RNG engine is truly random. A truly random RNG engine would never have that issue at all, yet any of the crypto rng engines are designed to have it as little as possible.
And yeah, that's exactly how Math.random() works, you got that perfectly

@rawr51919 rawr51919 linked a pull request Sep 19, 2023 that will close this issue
12 tasks
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.

2 participants