KeyPair generateKeyPair ( int keySize ) throws Exception { KeyPairGenerator generator = KeyPairGenerator . getInstance ( KEY_GENERATION_ALGORITHM , PROVIDER_NAME ) ; generator . initialize ( keySize , new SecureRandom ( ) ) ; return generator . generateKeyPair ( ) ; }
Create a random 2048 bit RSA key pair with the given length