Code example for KeyPair

Methods: getPrivategetPublic

0
        kpg.initialize(getKeyLength());
        KeyPair kp = kpg.generateKeyPair();
 
        Cipher cip = Cipher.getInstance(getAlgName() + "/" + getMode() + "/" +
                getPadding()); 
        cip.init(Cipher.ENCRYPT_MODE, kp.getPublic());
        cip.doFinal(input, 0, input.length, output);
        int outputSize = cip.getOutputSize(input.length);
        cip.init(Cipher.DECRYPT_MODE, kp.getPrivate());
        cip.doFinal(output, 0, outputSize, decrypted);
 
        checkEncodedData(input, decrypted);
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java