title: Consistent random numbers across versions and platforms
body: <p>I need/want to get random (well, not entirely) numbers to use for password generation.  </p>
  
  <p><strong>What I do</strong>: Currently I am generating them with <a href="http://docs.oracle.com/javase/7/docs/api/java/security/SecureRandom.html" rel="nofollow">SecureRandom</a>.<br>
  I am obtaining the object with</p>
  
  <pre><code>SecureRandom sec = SecureRandom.getInstance("SHA1PRNG", "SUN");
  </code></pre>
  
  <p>and then seeding it like this</p>
  
  <pre><code>sec.setSeed(seed);
  </code></pre>
  
  <p><strong>Target</strong>: A (preferably fast) way to create random numbers, which are cryptographically at least a safe as the SHA1PRNG SecureRandom implementation. These need to be the same on different versions of the JRE and Android.</p>
  
  <p>EDIT: The seed is generated from user input.</p>
  
  <p><strong>Problem</strong>: With <code>SecureRandom.getInstance("SHA1PRNG", "SUN");</code> it fails like this:
  <code>java.security.NoSuchProviderException: SUN</code>. Omitting <code>, "SUN"</code> produces random numbers, but those are different than the <em>default</em> (JRE 7) numbers.</p>
  
  <p><strong>Question</strong>: How can I achieve my <strong>Target</strong>? </p>
  
  <p><strong>You don't want it to be predictable</strong>: I want, because I need the predictability so that the same preconditions result in the same output. If they are not the same, its <s>impossible</s> <em>hard</em> to do what the user expects from the application.</p>
  
  <p>EDIT: By predictable I mean that, when knowing a single byte (or a hundred) you should not be able to predict the next, but when you know the seed, you should be able to predict the first (and all others). Maybe another word is <strong>reproducible</strong>.</p>
  
  <p>If anyone knows of a more intuitive way, please tell me!</p>