Here you can find the source of generateKeyPair(int len)
public static KeyPair generateKeyPair(int len)
//package com.java2s; /*//from w ww. j a v a 2s . c o m * Copyright (c) 2011-2012 ICM Uniwersytet Warszawski All rights reserved. * See LICENCE.txt file for licensing information. */ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; public class Main { public static KeyPair generateKeyPair(int len) { KeyPairGenerator kpGen; try { kpGen = KeyPairGenerator.getInstance("RSA"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("RSA algorithm not supported!?", e); } kpGen.initialize(len, new SecureRandom()); return kpGen.generateKeyPair(); } }