Here you can find the source of generateRSAKeyPair()
public static KeyPair generateRSAKeyPair() throws Exception
//package com.java2s; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.SecureRandom; public class Main { /**/*from www . j a va 2s .c o m*/ * Create a random 1024 bit RSA key pair */ public static KeyPair generateRSAKeyPair() throws Exception { KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC"); kpGen.initialize(1024, new SecureRandom()); return kpGen.generateKeyPair(); } }