Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / Java / JSP - How do I do RSA encryption?

Author
Message
Mr Z
17
Years of Service
User Offline
Joined: 27th Oct 2007
Location:
Posted: 15th Apr 2009 15:27 Edited at: 15th Apr 2009 15:32
Hi all.

Working on a chat program that will encrypt everything. But to do so I must understand encryption, so I started a simple project where I simply learn how to use encryption, and I am trying to figure out RSA at the moment (first best). All I get is errors. This is my code:



That code throws a BadPaddingException exception (can be found under javax.crypto), which state that the "Data must start with zero".

The exception is thrown when I try to decrypt the data, I can encrypt it without any problems. Anyone have any idea of what is wrong?

Take care,
Mr Z.

There is no greater virtue, then the ability to face oneself.
Mr Z
17
Years of Service
User Offline
Joined: 27th Oct 2007
Location:
Posted: 16th Apr 2009 12:30
Ok, I managed to sove it with the following code:


There is no greater virtue, then the ability to face oneself.

Login to post a reply

Server time is: 2025-05-13 05:48:01
Your offset time is: 2025-05-13 05:48:01