jeroen / gpg

Bindings to gpgme for R
Other
19 stars 4 forks source link

Password to decrypt directly in function #6

Open domingoscisci opened 5 years ago

domingoscisci commented 5 years ago

Hi, I need to decrypt the data to be used in a Rmarkdown script. Because Rmarkdown is not interactive, inserting the password is not possible. Is there a way to add a "password" attribute to the gpg_decrypt function? In Rmarkdown parameters can be used to safety prompt users for the password.

Thanks for your work! Domi

jmueller17 commented 4 years ago

Same problem here. Is there a solution to this?

dmkaplan2000 commented 4 years ago

I have the same problem and I have found that decrypting the file on the command line or evaluating by hand the corresponding chunk or line in the Rmarkdown script causes the keyring to request the password, which is then stored for a short time. During this time you can launch Rmarkdown and it will be able to decrypt the file without requesting the password...

thereelaristotle commented 4 years ago

I'm looking for the same exact thing. Trying to grab a file and decrypt as part of batch process.

I've given up and gone straight to the gpg.exe -- you can still load your key using the package functions.

The exe will be inside the directory with the gpg package.

./gpg.exe --batch --passphrase "PASSPHRASE" -d -o decryptedPath encryptedPath

To run it through R do something like this:

command <- paste("./R/win-library/3.5/gpg/bin/gpg.exe","--batch","--passphrase",paste0("\"", PASSPHRASE, "\""),"-d","-o",paste0("\"", decryptedFilePath, "\""),paste0("\"", encryptedFilePath, "\"")) system(command)