• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rakesh Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).

 
Rakesh Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you could explain in some more details it will help me more.
Thankx
Rakesh
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Rakesh Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rakesh Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic