Question is in the title, quite new here so don't know much about the site yet. Want to use hash for creating "more randomness" but not yet sure about Java's Math.Random() yet, is it possible to crack it?
- 
                    See http://franklinta.com/2014/08/31/predicting-the-next-math-random-in-java/ – Sumit Singh Oct 09 '15 at 10:23
- 
                    Your question is not at all clear, please can you explain what it is you want to know? – Andi Emma Davies Oct 09 '15 at 10:27
- 
                    What I mean is , is it possible to be able to guess the next number while using math.random() as a function for making random numbers. I wanted to try and improve the method by using hashes if Math.random is insecure. – PercyJackson Oct 10 '15 at 19:02
1 Answers
If you are using java.util.Random(), it is possible. Have a look at this Code
For better security, you have to use SecureRandom as below
SecureRandom secureRandomGenerator = SecureRandom.getInstance("SHA1PRNG");
But the best solution, which can't be cracked is using Hardware for Random number generation.
EDIT:
Algorithms based on Random like MersenneTwister can be hacked as per this article by Dan Petro
CSPRNGs (Cryptographically secure pseudorandom number generator)  to use are:
- Reading from - /dev/urandomon a Unix-like system
- The Java - SecureRandomclass
- The .NET - RNGCryptoServiceProviderclass
- The PHP - openssl_random_pseudo_bytes()function
In contrast, some examples of random number generators to avoid are:
- The - libc rand()function
- The Java Random class 
- The .NET Random class 
- PHP’s - rand()and mt_- rand()functions
Have a look at this article by Thomas Huhn
 
    
    - 37,698
- 11
- 250
- 211
