jeudi 20 août 2015

JDK 1.7 Secure Random Generator seeding & unpredictability

I am planning to implement MersenneTwister algorithm for random generation. Since it is not secure, looking for setting a seed derived from SecureRandom

SecureRandom secureRandomGenerator = SecureRandom.getInstance("SHA1PRNG");
int seedSize = 100; 
int[] seed = new int[seedSize]; 
for (int i=0; i <seedSize; i++) { 
    seed[i] = secureRandomGenerator.nextInt(Integer.MAX_VALUE); 
}
randomGenerator = new MersenneTwister(seed);

I have two queries

1) Is SHA1PRNG is good algorithm for unpredictability among its peers?

2) Setting a seed to SHA1PRNG is bad idea or good idea? If it is good idea, what is the best way to set seed for SHA1PRNG to improve unpredictability?




Aucun commentaire:

Enregistrer un commentaire