RSA public key exportation
Posted
by user308806
on Stack Overflow
See other posts from Stack Overflow
or by user308806
Published on 2010-05-06T22:44:20Z
Indexed on
2010/05/06
22:48 UTC
Read the original article
Hit count: 435
Dear all, Here is my code
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
KeyPair myPair = kpg.generateKeyPair();
PrivateKey k = myPair.getPrivate();
System.out.print(k.serialVersionUID);
Cipher c = Cipher.getInstance("RSA");
c.init(Cipher.ENCRYPT_MODE, myPair.getPublic());
String myMessage = new String("Testing the message");
byte[] bytes = c.doFinal(myMessage.getBytes());
String tt = new String(bytes);
System.out.println(tt);
Cipher d = Cipher.getInstance("RSA");
d.init(Cipher.DECRYPT_MODE, myPair.getPrivate());
byte[] temp = d.doFinal(bytes);
String tst = new String(temp);
System.out.println(tst);
My question is how can i get the public key and stored elsewhere
© Stack Overflow or respective owner