Here you can find the source of generateKeyPair(int keySize)
public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException, NoSuchProviderException
//package com.java2s; //License from project: LGPL import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; public class Main { private static final String KEYGEN_ALGORITHM = "RSA"; private static final String SECURE_RANDOM_ALGORITHM = "SHA1PRNG"; public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException, NoSuchProviderException { KeyPairGenerator generator = KeyPairGenerator.getInstance(KEYGEN_ALGORITHM/* , PROVIDER_NAME */); SecureRandom secureRandom = SecureRandom.getInstance(SECURE_RANDOM_ALGORITHM/* , PROVIDER_NAME */); generator.initialize(keySize, secureRandom); return generator.generateKeyPair(); }// ww w .jav a2 s. c o m }