Implement a RSA algorithm in Java

Posted by Robin Monjo on Stack Overflow See other posts from Stack Overflow or by Robin Monjo
Published on 2010-04-25T14:41:38Z Indexed on 2010/04/25 14:53 UTC
Read the original article Hit count: 502

Filed under:
|
|
|

Hello everyone.

I want to implement a RSA algorithm to encrypt an image (byte[]). To generate my two keys I used this piece of code :

KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
keygen.initialize(512);
keyPair = keygen.generateKeyPair();

Once public and private key are generated, I would like to show them to the user so he can distribute the public key and use the private key to decode. How can I get back those key?

Using keygen.getPrivateKey() and keygen.getPublicKey() give me all the information of the RSA algorithm, not only the keys I need.

Thanks

© Stack Overflow or respective owner

Related posts about rsa

Related posts about java