Cryptographically strong random numbers
Jon Ribbens
jon+usenet at unequivocal.co.uk
Fri Oct 16 14:10:03 EDT 2015
On 2015-10-16, Steven D'Aprano <steve at pearwood.info> wrote:
> If you have written crypto code that needs random numbers as described
> below, I am looking for your feedback.
>
> Python-Dev is arguing about which of the following three functions should be
> included:
>
> randbelow(end):
> return a random integer in the half-open interval 0...end
> (including 0, excluding end)
>
> randint(start, end):
> return a random integer in the closed interval start...end
> (including both start and end)
>
> randrange([start=0,] end [, step=1]):
> return a random integer in the half-open range(start, stop, step)
>
>
> It has been claimed that most applications of crypto random numbers will
> only need to generate them in the half-open range 0...end (excluding end).
> If you have experience with using crypto random numbers, do you agree?
> Which of the three functions would you use?
Given that the latter incorporates all of the functionality of the
former two without being noticeably more complicated, I don't see
why it isn't the obvious one to go for.
Also, isn't uuid4() an obvious shoo-in for this module too?
More information about the Python-list
mailing list