Java Key Pair Create generateKeyPair(int keysize)

Here you can find the source of generateKeyPair(int keysize)

Description

Generates a RSA key pair with the provided key size (in bits)

License

Open Source License

Declaration

public static KeyPair generateKeyPair(int keysize) throws NoSuchAlgorithmException 

Method Source Code

//package com.java2s;
/*//from w  ww.j av  a 2 s.c  om
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

import java.security.KeyPair;
import java.security.KeyPairGenerator;

import java.security.NoSuchAlgorithmException;

public class Main {
    /**
     * Generates a RSA key pair with the provided key size (in bits)
     */
    public static KeyPair generateKeyPair(int keysize) throws NoSuchAlgorithmException {
        // generate a private key
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
        keyPairGenerator.initialize(keysize);
        return keyPairGenerator.generateKeyPair();
    }
}

Related

  1. generateKeyPair(int bit)
  2. generateKeyPair(int keySize)
  3. generateKeyPair(int keySize)
  4. generateKeyPair(int keySize)
  5. generateKeyPair(int keySize)
  6. generateKeyPair(int keySize, String fileChavePublica, String fileChavePrivada)
  7. generateKeyPair(int keySizeInBits, String algo)
  8. generateKeyPair(int len)
  9. generateKeyPair(int size)