Ashwin
Ashwin

Reputation: 13547

using sha1prng in both android and windows giving different sequences

I have used sha1prng in both my android program and java program as the pseudo ramdom number generator algorithm. I seeded both of them with the same value.

But the sequesnce generated in android is different from the one generated in java. Why is this happening and what is the solution to this problem?

Upvotes: 3

Views: 789

Answers (1)

Rubi Sharmax
Rubi Sharmax

Reputation: 376

I think it's because SHA1PRNG implementations on Windows and Android are different. Android uses Crypto as the provider while Windows SDK uses Sun JCE provider as SHA1PRNG implementation. The output sequence with the same seed differes even in different versions of JDK as it's discussed here: http://www.derkeiler.com/Newsgroups/sci.crypt/2006-04/msg00765.html. For different implementations of SHA1PRNG you may want to check this link: http://www.cigital.com/justice-league-blog/2009/08/14/proper-use-of-javas-securerandom/.

Upvotes: 5

Related Questions