Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

If I encrypt a file with gpg -c file.zip, and change the filename. Is there any way I can restore the filename as I used as a password. or the name encrypted to?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Yes, gpg -c file.zip does encode the input file name in the encrypted packet.

The gpg man page documents a few relevant options:

--set-filename string

Use string as the name of file which is stored in messages.

This overrides the default, which is to use the actual filename of the file being encrypted.

--use-embedded-filename

Try to create a file with a name as embedded in the data. This can be a dangerous option as it allows to overwrite files.

This defaults to no.

share|improve this answer
    
I understand this option so that the filename is inside the message. So the original author cannot reveal it without knowing the password. –  qbi Nov 1 '12 at 22:13
    
@ Ilmari Karonen, i try gpg --use-embedded-filename filename.gpg but it ask for password and not shown the old file name, did u mean 'This defaults to no.' that i should use the option before encrypt the file or it work by default. –  illsecure Nov 15 '12 at 7:11
    
@illsecure: GPG will always ask for the password when decrypting symmetrically encrypted data. The original filename (if any) is stored inside the encrypted data packet, so GPG needs the password to decrypt it. –  Ilmari Karonen Nov 15 '12 at 12:15
    
so there are no way to save the file name inside the gpg file so I can read before give the password, thats all thanks for your answer. –  illsecure Nov 16 '12 at 5:00

Usually there is no way to recover the old filename. If you change the name of a file, GnuPG doesn't know about this. Maybe you have backups and can recover the filename from there. Or you have to try to remember what the name was.

share|improve this answer
    
understood, thanks –  illsecure Nov 1 '12 at 16:21
    
You can accept an answer in 6 minutes, so 'll wait may be some one hve a way to recover the name. –  illsecure Nov 1 '12 at 16:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.