ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Get the original filename before encryption #119

Open llopez opened 6 years ago

llopez commented 6 years ago

I am working on a project in which I have to decrypt some gpg files that do not come with the file extension explicit, just data.gpg

It would be very useful to be able to get the original filename.

kernelsmith commented 6 years ago

I think this is related to #62, #99 except --use-embedded-filename would have to be exposed. Although, I should point out GnuPG considers this option to be unsafe: "This can be a dangerous option as it enables overwriting files. Defaults to no." https://www.gnupg.org/documentation/manuals/gnupg/GPG-Esoteric-Options.html#index-use_002dembedded_002dfilename (search for "--use-" as this link doesn't quite take you to the right option). You can get around this by naming the outputted gpg file like the_name_i_want.zip.gpg. Most gpg clients will simply strip off the .gpg (or .asc) and use the remaining part as the filename. Some (especially GUI clients) have an option to do this that needs to be turned on first.

adet4ever commented 5 years ago

is there a way to set the file name or a name for encryption?

    crypto = GPGME::Crypto.new
    options = @options
    data = crypto.encrypt byte_array, options
    data.file_name=('sample_file_name')

Such that the output file has a name? When the encrypted string is written to a file? For example:

gpg --list-packets outt.gpg

:literal data packet: mode b (62), created 1547573148, name="", raw data: 23 bytes