Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to decrypt the last block.

843810Feb 6 2005 — edited Apr 22 2008
Hi
I am using the Bouncy Castle RSA implementation. The thing is that i am able to successfully encode and decode the files. But the problem is with the last block.
I am using for encryption the following piece of code.

byte[] buf = new byte[100];
while(read!=-1)
{
read = bis.read(buf);
byte buff2 []=c.doFinal(buff);
if(read>=0)
fr.write(buff2);
}
and for the Decryption I use the inverse of the above code. with the only difference that now my buf = new byte[128]. But the thing is that i get some junk bytes at the end of the last block......because of the padding effect. Is there any way i can get rid of this junk values.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 20 2008
Added on Feb 6 2005
9 comments
483 views