Here you can find the source of generateKeyPair()
public static KeyPair generateKeyPair() throws Exception
//package com.java2s; //License from project: Open Source License import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.SecureRandom; public class Main { public static KeyPair generateKeyPair() throws Exception { KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC"); kpGen.initialize(1024, new SecureRandom()); return kpGen.generateKeyPair(); }/*w w w . j a va 2s . co m*/ }