performance - How to solve slow Java `SecureRandom`? -


if want cryptographically strong random number in java, use securerandom. unfortunately, securerandom can slow. if uses /dev/random on linux, can block waiting sufficient entropy build up. how avoid performance penalty?

has used uncommon maths solution problem?

can confirm performance problem has been solved in jdk 6?

if want true random data, unfortunately have wait it. includes seed securerandom prng. uncommon maths can't gather true random data faster securerandom, although can connect internet download seed data particular website. guess unlikely faster /dev/random that's available.

if want prng, this:

securerandom.getinstance("sha1prng"); 

what strings supported depends on securerandom spi provider, can enumerate them using security.getproviders() , provider.getservice().

sun fond of sha1prng, it's available. isn't fast prngs go, prngs crunching numbers, not blocking physical measurement of entropy.

the exception if don't call setseed() before getting data, prng seed once first time call next() or nextbytes(). using small amount of true random data system. call may block, make source of random numbers far more secure variant of "hash current time pid, add 27, , hope best". if need random numbers game, though, or if want stream repeatable in future using same seed testing purposes, insecure seed still useful.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -