1

Using GnuPG one can symmetrically encrypt a file using:

gpg -c --cipher-algo TWOFISH --digest-algo SHA512 secret.txt 

and decrypt using:

gpg -d -o secret.txt secret.txt.gpg 

After running these commands a window pops up and asks for the password. I would like to run these commands out of a program using golangs 'exec' or pythons 'os.system'. How do I suppress this window and pass the password via command line? I couldn't find something like a --password option in the man pages.

migrated from crypto.stackexchange.com Jan 20 '15 at 13:34

This question came from our site for software developers, mathematicians and others interested in cryptography.

  • As far as I know, the window is created by the pinetry program. If you uninstall it you'll have a dialog directly in the shell. – ddddavidee Jan 19 '15 at 8:57
3

You have some choices:

echo "aqw" | gpg --batch --passphrase-fd 0 -d -o output.txt secret.txt.gpg

or

gpg --batch --passphrase "aqw" -d -o output.txt secret.txt.gpg

or

gpg --batch --passphrase-file passphrase.txt -d -o output.txt secret.txt.gpg

(if you don't want to write your passphrase into the commandline)

  • 4
    None of these seem to work with mit GPG installation. – Stein Jan 19 '15 at 18:37
  • it works on mine: Debian unstable. – ddddavidee Jan 20 '15 at 16:02
  • I use Mint and gpg 1.4.16 could you post your GPG version? – Stein Jan 20 '15 at 16:14
  • On my debian unstable I've: gnupg 1.4.18-6 – ddddavidee Jan 20 '15 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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