c++ arc4random on android, windows and linux

Turns out native android development doesn’t supply you with a real ar4random method. However adapting the OpenBSD’s arc4random.c does the trick. And even works on windows without using CryptoAPI (thanks to Chris K. Jester-Young for these suggestions). Additionally with boost *ducks* it should be more or less multithreadsafe.

Mixed (red dots are generated by arc4; Math.Random() Arc4random)

And here are the convinience methods for it:

So you can use it like:

Enjoy. (:

See also

Facebook comments:

comments

3 Comments

  1. Hi all, i’m trying to using the file above in a project. I’ve installed boost binaries and i’m trying to compile the project for 64bit target in Visual Studio 2013. But i have a lot of errors about boost libs. Seems that boost libs does not like to be included in a .c file. Any idea?
    thanks

Leave a Reply to f4grx Cancel reply