Code example for DHParameterSpec

0
 
    public static void main( 
        String[]    args)
        throws Exception 
    { 
        DHParameterSpec             dhParams = new DHParameterSpec(p512, g512);
 
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH", "BC");
 
        keyGen.initialize(dhParams, Utils.createFixedRandom());
 
        // set up 
        KeyAgreement aKeyAgree = KeyAgreement.getInstance("DH", "BC");
        KeyPair      aPair = keyGen.generateKeyPair();
        KeyAgreement bKeyAgree = KeyAgreement.getInstance("DH", "BC");
        KeyPair      bPair = keyGen.generateKeyPair();
         
        // two party agreement 
        aKeyAgree.init(aPair.getPrivate());
        bKeyAgree.init(bPair.getPrivate());
Stop searching for code, let great code find you!  Add Codota to your java IDE