Source Code : KeyPair Generator For Private Key

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

KeyPair Generator For Private Key

   
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.security.Security;

public class MainClass {
  public KeyPair generateKeyPair(long seed)throws Exception {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    KeyPairGenerator keyGenerator = KeyPairGenerator.getInstance("DSA");
    SecureRandom rng = SecureRandom.getInstance("SHA1PRNG", "SUN");
    rng.setSeed(seed);
    keyGenerator.initialize(1024, rng);

    return (keyGenerator.generateKeyPair());
  }

  public static void main(String args[]) throws Exception {
    MainClass kpge = new MainClass();
    KeyPair kp = kpge.generateKeyPair(999);
    System.out.println("
-- Private Key ----");
    PrivateKey priKey = kp.getPrivate();
    System.out.println("   Algorithm=" + priKey.getAlgorithm());
    System.out.println("   Encoded=" + priKey.getEncoded());
    System.out.println("   Format=" + priKey.getFormat());
  }
}

           
         
    
    
  

Thank with us