# Does gpg's symmetric encryption keep information about the filename?

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?

-

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.

-
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.

-
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