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 number generation docs should mention ints #2190

Closed
alex opened this issue Aug 2, 2015 · 6 comments
Closed

Random number generation docs should mention ints #2190

alex opened this issue Aug 2, 2015 · 6 comments

Comments

@alex
Copy link
Member

alex commented Aug 2, 2015

https://cryptography.io/en/latest/random-numbers/ doesn't say what to do if you want an integer, instead of bytes.

@alex
Copy link
Member Author

alex commented Aug 3, 2015

int.from_bytes(os.urandom(16), "big") is strictly speaking the right answer.

@alex
Copy link
Member Author

alex commented Aug 3, 2015

Except python 2.6 :-(

@alex
Copy link
Member Author

alex commented Aug 3, 2015

A fun test might be to just put the int.from_bytes() bit in teh docs and see who complains?

@wbond
Copy link

wbond commented Aug 3, 2015

Probably everyone who is using Python 2.7 will complain also since it is 3.2+.

@alex
Copy link
Member Author

alex commented Aug 8, 2015

@reaperhulk do you have thoughts about whether to recommend int.from_bytes (py3 only), make our int_from_bytes public, or some third option I haven't thought of.

@reaperhulk
Copy link
Member

I'm inclined to say int.from_bytes() or int(uuid.UUID4()) ("only" 128-bit, but py2/py3)

@alex alex closed this as completed in 4c360e4 Aug 8, 2015
reaperhulk added a commit that referenced this issue Aug 8, 2015
Document how to get a random number as an integer, fixes #2190
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants