title: Generate KeyPair with RandomSecure
body: <p>Is there anyway I can generate always the same private key? I tired to initialize <a href="https://docs.oracle.com/javase/7/docs/api/java/security/KeyPairGenerator.html" rel="nofollow">KeyPairGenerator</a> with a <a href="https://docs.oracle.com/javase/7/docs/api/java/security/SecureRandom.html#SecureRandom%28byte[]%29" rel="nofollow">RandomSecure</a> object which uses the same <code>seed</code>:</p>
  
  <pre><code>private PrivateKey getPrivateKey(String seed) {
      try {   
          SecureRandom sr = new SecureRandom(seed.getBytes());
  
          KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
          keyGen.initialize(1024, sr);
          KeyPair keyPair = keyGen.generateKeyPair();
          return keyPair.getPrivate();
      } catch (NoSuchAlgorithmException e) {
          System.out.println("Failed to generate key pair!");
      }
      return null;
  }
  </code></pre>
  
  <p>I invoke the above function and check if the private keys are the same:</p>
  
  <pre><code>String seed = "xyzabc123";
  PrivateKey key1 = getPrivateKey(seed);
  PrivateKey key2 = getPrivateKey(seed);
  
  boolean same = key1.equals(key2); // false
  </code></pre>
  
  <p>They are different, my question is is there a way to generate always the same private key ?</p>