Here you can find the source of getKeyPair()
public static KeyPair getKeyPair() 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_ALGORITHM = "RSA"; private static final int KEY_SIZE = 512; public static KeyPair getKeyPair() throws Exception { KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM); kpGenerator.initialize(KEY_SIZE); KeyPair keyPair = kpGenerator.generateKeyPair(); return keyPair; }//w w w . ja v a 2 s . c o m }