Is there a thread-safe RNG in Bionic? For Linux, I know there is rand_r()
, but this is unfortunately not a part of the NDK.
Asked
Active
Viewed 542 times
0

Android Noob
- 3,271
- 4
- 34
- 60
-
The Linux man pages say `rand_r` is obsolete. `random_r` seems to be current... but it too doesn't exist in bionic. There are a lot of open-source RNGs out there, tuned to different things (speed, low periodicity, etc), so you may just want to grab one and build it in. – fadden Dec 11 '12 at 01:10
1 Answers
0
You can simply read from /dev/urandom/
to get pseudo-random bytes. If you need this for cryptographic purposes, you may want to look into OpenSSL as well.

Nikolay Elenkov
- 52,576
- 10
- 84
- 84