aspose file tools
The moose likes Security and the fly likes How to multiple-part encrypt a String with RSA? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » Security
Reply Bookmark "How to multiple-part encrypt a String with RSA?" Watch "How to multiple-part encrypt a String with RSA?" New topic
Author

How to multiple-part encrypt a String with RSA?

Andrew Carney
Ranch Hand

Joined: Oct 17, 2006
Posts: 96
Hello,

I am looking for a code sample to multiple-part encrypt a String which is larger than the limit allowed by RSA.
I'm assuming it can be done with the doFinal and update methods of the Cipher object but couldn't get it to work.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 3688

Most folks don't do it that way. RSA only works on blocks of the key length. The normal approach is to generate a random number/nonce, encrypt it with RSA and send it. Then use that random nonce to encipher the long string, send that too. On the receiving end, use RSA to decrypt the nonce, and use it to decrypt the rest of the message.

 
 
subject: How to multiple-part encrypt a String with RSA?
 
Threads others viewed
Java and Javascript intearaction
CipherOutputStream not outputing
Java and Javascript intearaction
Java and Javascript intearaction
encrypt the query string in java
developer file tools