Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I encrypt a file with gpg -c, 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
up vote 2 down vote accepted

Yes, gpg -c 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.


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


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.