Skip to content

Conversation

@svanstone-resilient
Copy link

Previously only returned from 0 to 0.5. This removed 2 bits of entropy from the generated cuids.
This is a replacement for Math.random() and as such it should return from 0 to 1 (but never return 1 exactly), therefore lim was also modified.
The returned value now has about 30 to 32 bits of entropy. This is probably enough for this library (it gets truncated to 20 bits later), but you could consider using something like this library:
https://github.com/emilbayes/secure-random-double/blob/master/index.js
Which would allow you to get 51 or 52 bits of entropy into the return value.

Previously only returned from 0 to 0.5. This removed 2 bits of entropy from the generated cuids.
This is a replacement for Math.random() and as such it should return from 0 to 1 (but never return 1 exactly), therefore lim was also modified.
The returned value now has about 30 to 32 bits of entropy. This is probably enough for this library (it gets truncated to 20 bits later), but you could consider using something like this library:
https://github.com/emilbayes/secure-random-double/blob/master/index.js
Which would allow you to get 51 or 52 bits of entropy into the return value.
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 this pull request may close these issues.

1 participant