Skip to content

Instantly share code, notes, and snippets.

@ryctabo
Last active February 4, 2018 21:44
Show Gist options
  • Save ryctabo/5b158c3266b7243f2d736c19967b1c06 to your computer and use it in GitHub Desktop.
Save ryctabo/5b158c3266b7243f2d736c19967b1c06 to your computer and use it in GitHub Desktop.
Get instance of KeyPairGenerator class
try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024);
KeyPair keyPair = keyPairGenerator.generateKeyPair();
PublicKey publicKey = keyPair.getPublic();
PrivateKey privateKey = keyPair.getPrivate();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment