Here you can find the source of generateKeyPair(int bit)
public static KeyPair generateKeyPair(int bit) throws Exception
//package com.java2s; //License from project: Apache License import java.security.KeyPair; import java.security.KeyPairGenerator; public class Main { private static final String KEY_ALGORTHM = "RSA"; public static KeyPair generateKeyPair(int bit) throws Exception { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGORTHM); keyPairGenerator.initialize(bit); KeyPair keyPair = keyPairGenerator.generateKeyPair(); return keyPair; }/*w ww.j a va2 s . c o m*/ }