File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes RAS+public private key encrypt +decrypt+ file size larger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "RAS+public private key encrypt +decrypt+ file size larger" Watch "RAS+public private key encrypt +decrypt+ file size larger" New topic
Author

RAS+public private key encrypt +decrypt+ file size larger

Rakesh Kumar
Ranch Hand

Joined: May 30, 2006
Posts: 63
Dear friends,
I am doing encrypting decrypting of any type files using My RSA+private key ,public key alogorithm in java.
My issue is wheever i enctyprt any .tar files the size of the encrypted file is larger than the original .tar file.
But encryption is ok and decryption also ok.

Thanks
Rakesh
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Rakesh Kumar wrote:Dear friends,
I am doing encrypting decrypting of any type files using My RSA+private key ,public key alogorithm in java.
My issue is wheever i enctyprt any .tar files the size of the encrypted file is larger than the original .tar file.
But encryption is ok and decryption also ok.

Thanks
Rakesh


Unless you compress a file first, it is almost certain that the encrypted file will be longer than the original. This applies pretty much regardless of the encryption method since one normally has to apply some form of padding and one has to ship some ancillary information such as a random initialisation value (IV).


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Rakesh Kumar
Ranch Hand

Joined: May 30, 2006
Posts: 63
If you could explain in some more details it will help me more.
Thankx
Rakesh
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Rakesh Kumar wrote:If you could explain in some more details it will help me more.
Thankx
Rakesh


What more can one say! The subject is large and I don't intend to write a book on the subject and post it here. If you are really serious about the topic then, as a starting point, you should read "Beginning Cryptography with Java" written by David Hook and published by Wrox.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

Why is it a problem?

The point of encryption is to hide the data, or make it impossible to read without knowing the key. It is NOT supposed to compress the data. I doubt any encryption tool says it would keep the file the same size. Pretty much by nature of what it does, it has to add bytes in here and there.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rakesh Kumar
Ranch Hand

Joined: May 30, 2006
Posts: 63
Dear friend I am able to encrypt the file but with some considerable increase in size .And later we can decrypt the file also..

The size incriment of the output of the decryption happens.

Thanks
Rakesh
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

So what you are saying is that you have a file that is X bytes, you encrypt it, then decrypt it, and the final result of that is X+delta bytes?
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Rakesh Kumar wrote:Dear friend I am able to encrypt the file but with some considerable increase in size .And later we can decrypt the file also..

The size incriment of the output of the decryption happens.

Thanks
Rakesh


Then you have a bug in either or both of your encryption and decryption routines. Of course if we could see the code we could possibly help but ...
Rakesh Kumar
Ranch Hand

Joined: May 30, 2006
Posts: 63
Dear friend ,
I tried to attach ans send the sample files but some error is coming.
Can you please send me your email id so that i can send files directly to you.

Thanks for your support in this problem.
raakesh
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Rakesh Kumar wrote:Dear friend ,
I tried to attach ans send the sample files but some error is coming.
Can you please send me your email id so that i can send files directly to you.

Thanks for your support in this problem.
raakesh


I don't publish an email address and I don't enter into private correspondence . Your code should not be more than about 50 lines long (if it is then it includes far too much that is not concerned with the cryptography) so try again.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Rakesh Kumar wrote:I tried to attach ans send the sample files but some error is coming.

Text files can not be attached. James is right, the relevant code should not be long - just post it in CODE tags.


Ping & DNS - updated with new look and Ping home screen widget
Rakesh Kumar
Ranch Hand

Joined: May 30, 2006
Posts: 63
Dear friends I got one sample from one site it will encrypt the files without increasing the size.
Thanks for the support and suggestion of all of you people and very appreciable your efforts to help in case of technical issues.
Expecting more help from you people.

Thanks
rakesh
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Rakesh Kumar wrote:Dear friends I got one sample from one site it will encrypt the files without increasing the size.


Then the 'sample' is most probably flawed since the ancillary information such as padding and IV will in general add to the overall size.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RAS+public private key encrypt +decrypt+ file size larger
 
Similar Threads
K&B doubt regarding question in Development chapter
how is 'encapsulation' broken in this situation of mine ?
2 in 1 Question
Create Java executables
problem in XOR of private key using public key....