public static RSAKey keyGen(int keySize) {

        KeyPairGenerator generator = null;
        try {
            generator = KeyPairGenerator.getInstance(algorithm);
            generator.initialize(keySize);

            KeyPair keyPair = generator.generateKeyPair();

            return new RSAKey(keyPair.getPublic(), keyPair.getPrivate());
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return null;
    }
public static RSAKey keyGen ( int keySize ) { KeyPairGenerator generator = null ; try { generator = KeyPairGenerator . getInstance ( algorithm ) ; generator . initialize ( keySize ) ; KeyPair keyPair = generator . generateKeyPair ( ) ; return new RSAKey ( keyPair . getPublic ( ) , keyPair . getPrivate ( ) ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } return null ; }
RSA 公密钥对生成
<p>Function: keyGen</p>
<p>Description: </p>

@param keySize
@return Key数组  index = 0 公钥 | index = 1 私钥
@throws NoSuchAlgorithmException
@throws FileNotFoundException
@throws IOException
@author acexy@thankjava.com
@date 2016年8月10日 下午5:31:36
@version 1.0