Is there a java equivalent to OpenSSL's bn_rand_range?
问题 Specifically, I just want to generate a cryptographically secure random number between 0 and some number x . In OpenSSL this is done with the function bn_range . I can implement it myself using Java's BigInteger(int bits, Random r) constructor (which generates a number from 0 to 2 bits ). But I would like, if possible, to use a better tested algorithm for the sake of security. Is there a standard way to do this in Java? P.S. I am actually using Android, but I don't know how to do it in