Created
February 17, 2011 12:30
-
-
Save zaki50/831620 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); | |
kpg.initialize(new RSAKeyGenParameterSpec(2048, RSAKeyGenParameterSpec.F4)); | |
Log.i("hamatz", "generating RSA key pair..."); | |
final long start = SystemClock.uptimeMillis(); | |
final KeyPair kp = kpg.generateKeyPair(); | |
final long end = SystemClock.uptimeMillis(); | |
Log.i("hamatz", "done: " + (end-start) + "ms."); | |
final RSAPrivateKey privkey = (RSAPrivateKey) kp.getPrivate(); | |
final RSAPublicKey pubkey = (RSAPublicKey) kp.getPublic(); | |
final byte[] encodedPrivkey = privkey.getEncoded(); | |
final byte[] encodedPubkey = pubkey.getEncoded(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment