Generate DSA key pair : Key Generator « Security « Java






Generate DSA key pair

    

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

public class MainClass {

  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.Using the KeyGenerator class and showing how to create a SecretKeySpec from an encoded key
2.Key Generator Mac
3.KeyPair Generator For Private Key
4.KeyPair Generator For Public Key
5.Wrap And Unwrap Key
6.Generating a Public/Private Key Pair
7.Generate a 576-bit DH key pair
8.Generate a 1024-bit RSA key pair
9.Getting the Bytes of a Generated Key Pair
10.Get the bytes of the public and private keys
11.The bytes can be converted back to public and private key objects
12.Generate a key for the HMAC-SHA1 keyed-hashing algorithm
13.Asymmetric Key Maker
14.Generating a Symmetric Key
15.Xml dap Certs And Keys
16.Diffie-Hellman key exchange