KeyPairGenerator: generateKeyPair() : KeyPairGenerator « java.security « Java by API






KeyPairGenerator: generateKeyPair()

  


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

public class Main {

  public static void main(String[] args) throws Exception {

    KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
    kpg.initialize(1024, new SecureRandom());
    KeyPair dsaKeyPair = kpg.generateKeyPair();

  }
}

   
    
  








Related examples in the same category

1.KeyPairGenerator: genKeyPair()
2.KeyPairGenerator: getInstance(String algorithm) throws NoSuchAlgorithmException
3.KeyPairGenerator: initialize(int keysize)