List of utility methods to do Key Pair Create
KeyPair | generateKeyPair() Create new public & private keys with length 4096. return generateKeyPair(DEFAULT_KEY_LENGTH);
|
KeyPair | generateKeyPair() generate Key Pair try { KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ASYM_ALGORITHM); SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); keyGen.initialize(512, random); return keyGen.generateKeyPair(); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("No such algorithm:" + e.getMessage()); |
KeyPair | generateKeyPair() generate Key Pair KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", "BC"); kpGen.initialize(1024, new SecureRandom()); return kpGen.generateKeyPair(); |
void | generateKeyPair() generate Key Pair try { KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); SecureRandom random = new SecureRandom(); random.setSeed(System.currentTimeMillis()); generator.initialize(1024, random); KeyPair keyPair = generator.generateKeyPair(); RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); ... |
KeyPair | generateKeyPair() generate Key Pair KeyPairGenerator keyPairGenerator = null; try { keyPairGenerator = KeyPairGenerator.getInstance(ALGORITHM); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); keyPairGenerator.initialize(KEYSIZE); KeyPair keyPair = keyPairGenerator.generateKeyPair(); ... |
KeyPair | generateKeyPair() Generate a random key pair. KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN"); keyGen.initialize(1024, random); return keyGen.generateKeyPair(); |
KeyPair | generateKeyPair() generate Key Pair final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("EC"); final SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); keyPairGenerator.initialize(256, random); final KeyPair keyPair = keyPairGenerator.generateKeyPair(); return keyPair; |
KeyPair | generateKeyPair() Generates key-pair with KeyUtils#DEFAULT_KEY_ALGORITHM algorithm and KeyUtils#DEFAULT_KEY_SIZE key size. return generateKeyPair(DEFAULT_KEY_ALGORITHM, DEFAULT_KEY_SIZE);
|
KeyPair | generateKeyPair() generate Key Pair try { KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(2048); KeyPair kp = keyGen.genKeyPair(); return kp; } catch (Exception e) { throw new RuntimeException(e); |
KeyPair | generateKeyPair() Generates a keypair (public and private) based on Elliptic curves. ECGenParameterSpec ecGenSpec = new ECGenParameterSpec("secp384r1"); KeyPairGenerator g; try { g = KeyPairGenerator.getInstance("ECDSA", BC_PROVIDER_NAME); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new RuntimeException(e.getMessage(), e); try { ... |