Closed ghost closed 4 years ago
Sorry for letting this sit for too long.
Some comments:
randomint()
for random_int32()
to make it explicit what it actually returns. I think Erlang readers might try to write stuff like randomint(0, 10000000000000000000000)
and expect this to work.<<I:32/integer>> = enacl;randombytes(4)
in any way? I know the /1
and /2
variants are, but the /0
variant is what I'm thinking about. In short, do we really need this interface?Long overdue, but I've implemented enacl:randombytes_uint32/0
and enacl:randombytes_uniform/1
on master
now.
There are some changes compared to this proposal:
I've opted to not implement randombytes_uniform/2
:
libsodium
. It isn't in e.g., the Go rand
package.N+1
if you want the upper bound included.
This pull request is for functions generating random integers.
randomint/0 returns an unpredictable value between 0 and 0xffffffff (included). randomint/1 function returns an unpredictable value between 0 and given upper bound (excluded) randomint/2 function returns an unpredictable value between lower and upper bounds (included)
NOTE: The documentation for randomint/2 may be incorrect.