Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Find the original file size of encrypted file

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
vsachan vsachan is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 19 July 2017, 12:28 PM EDT
Posts: 41
Thanks: 10
Thanked 0 Times in 0 Posts
Computer Find the original file size of encrypted file

Hi,
I am trying to find out the original file size of an encrypted file in SunOS.
The file was decrypted with gpg command.

I want to know the size of the orginal file without decrypting it. I am using the below command, but it is not working for big files(more than 1 GB).

Code:
gpg --passphrase "password" --list-packets <File-Name>

Please help me to find the size of original files without decrypting the data as ther are many files.

Thanks,
Vipin


Moderator's Comments:
Find the original file size of encrypted file
Please wrap all code, files, input & output/errors in CODE tags.
it makes it easier to read and preserves multiple spaces for indenting or fixed-width data.

Last edited by rbatte1; 1 Week Ago at 11:26 AM.. Reason: Code tags
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 24 July 2017, 10:22 AM EDT
Location: Lancashire, UK
Posts: 3,168
Thanks: 1,334
Thanked 604 Times in 546 Posts
Could you try:-
Code:
gpg -d --passphrase "password" filename | wc -c

Does that do what you need?

The --list-packets option apparently .... List only the sequence of packets. according to my manual pages, and this won't give you the file size, if that's what you are after.



I hope that this helps,
Robin
The Following User Says Thank You to rbatte1 For This Useful Post:
vsachan (5 Days Ago)
Sponsored Links
    #3  
Old Unix and Linux 5 Days Ago
vsachan vsachan is offline
Registered User
 
Join Date: Jan 2011
Last Activity: 19 July 2017, 12:28 PM EDT
Posts: 41
Thanks: 10
Thanked 0 Times in 0 Posts
Thanks rbatte1....its working and giving me the result. But it is very slow, if it is a large file.Could you help me to find is there any way we can make the execution fast for this command.
    #4  
Old Unix and Linux 5 Days Ago
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 24 July 2017, 9:22 PM EDT
Location: NM
Posts: 11,118
Thanks: 549
Thanked 1,075 Times in 997 Posts
Except that in order to write to a pipe the result has to be decrypted first.

I saw this request earlier and could not think of a way around the requirement of reading the entire file and decrypting the data.

It seems to me like you may not see what is really going on. rbatte's example is very good but it does open and read the file.

You could also decrypt the file to /tmp (tmpfs file system) which in solaris is actually memory manged by the kernel. Not disk. Very fast. Pipes can be implemented as shared memory objects as well. If you do that, delete all the files in /tmp as you go.
Sponsored Links
    #5  
Old Unix and Linux 4 Days Ago
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 24 July 2017, 10:22 AM EDT
Location: Lancashire, UK
Posts: 3,168
Thanks: 1,334
Thanked 604 Times in 546 Posts
i think that if you have a huge input file, it will take time whatever method you use. There is no table-of-contents idea, so there is no way to know what the expected size will be. Perhaps you could consider a different approach:-
  • Get the file name & size of the plain file before encryption
  • Get a checksum of the file after encryption and link to the above
When you need the information, you can get the values from wherever you stored it a validate that the encrypted file is the same one by generating the current checksum.

It will still read the file to generate the checksum when you want to validate it, but it does not need to do decryption processing, so that might save a bit.


Basically though, large files will take time.......



Robin
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get original file size of zipped file forums123456 Shell Programming and Scripting 6 01-24-2012 03:39 PM
How to know the Original size of the file without unzipping the File? Siva Sankar UNIX for Dummies Questions & Answers 4 01-04-2012 10:32 AM
CSV file:Find duplicates, save original and duplicate records in a new file arvindosu UNIX for Dummies Questions & Answers 8 07-05-2011 04:48 PM
The scripts not able to make the file to size 0, every times it go back to its original size mridul10_crj Shell Programming and Scripting 0 10-03-2010 05:55 AM



All times are GMT -4. The time now is 02:37 AM.