Vishal N
Vishal N

Reputation: 11

How to use RSA private keys using Java

I want to use the RSA private key in my project using Java. I do have the key in file using PEM format. I want to use this private key into my project to decrypt the messages which are encrypted using my public key.

What is the method/standard classes I can use to read and decode the private key from the PEM file? I don't want to use the openssl or any other libraries/classes to do this. An example or sample code will be really helpful.

Vishal N

Upvotes: 0

Views: 4029

Answers (2)

President James K. Polk
President James K. Polk

Reputation: 41958

The Bouncycastle PEMReader class will do what you want. If you insist on not using the Bouncycastle library then you can simply look at the source code for the class to see how they do it.

Upvotes: 1

nikhil
nikhil

Reputation: 9385

You Might Want to go through the following links :

Stack Overflow Older Question

and

Java RSA Encryption Sample Code

Upvotes: 0

Related Questions