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

Chrome extension shouldn’t use modulus to fit random values to wordlist #2

Open
s4y opened this issue Oct 8, 2012 · 0 comments
Open
Assignees

Comments

@s4y
Copy link
Member

s4y commented Oct 8, 2012

Using mod to fit random numbers to a range means that the words in the list that could be hit by the mod are twice as likely to be chosen as those that aren’t. 💥

I think the canonical way to handle this is, instead, to keep generating random numbers until you get one that's in range.

Here’s a good example from Python: http://hg.python.org/cpython/file/default/Lib/random.py#l216

@ghost ghost assigned omni5cience Oct 8, 2012
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

No branches or pull requests

2 participants