Generating a Parameter Set for the Diffie-Hellman Key Agreement Algorithm : Algorithms « Security « Java






Generating a Parameter Set for the Diffie-Hellman Key Agreement Algorithm

  

import java.security.AlgorithmParameterGenerator;
import java.security.AlgorithmParameters;

import javax.crypto.spec.DHParameterSpec;

public class Main {
  public static void main(String[] argv) throws Exception {
    AlgorithmParameterGenerator paramGen = AlgorithmParameterGenerator.getInstance("DH");
    paramGen.init(1024);

    AlgorithmParameters params = paramGen.generateParameters();
    DHParameterSpec dhSpec = (DHParameterSpec) params.getParameterSpec(DHParameterSpec.class);

    System.out.println("" + dhSpec.getP() + "," + dhSpec.getG() + "," + dhSpec.getL());
  }
}

   
    
  








Related examples in the same category

1.What is in bouncycastle (bouncy castle)
2.JCE algorithms in BrowserJCE algorithms in Browser
3.Listing All Available Cryptographic Services
4.Return the available implementations for a service type
5.Get cryptographic security providers