Search code examples
rubygnupggpgme

A different symmetric algo for gpgme


By default, gpg2 uses CAST5 for a symmetric encryption. Here

crypto = GPGME::Crypto.new()
r = crypto.encrypt "Hello world!\n", symmetric: true

r.read() will return CAST5 data.

How to change the default cipher algo to, for example, AES256?


Solution

  • Well, apparently it's not possible to change the cipher through the API, but is possible w/ an indirect trick.

    1. Create a tmp directory /foo/bar & put in it gpg.conf file w/ the line:

      personal-cipher-preferences aes256
      
    2. Set a 'home' directory for gpgme (before GPGME::Crypto.new):

      GPGME::Engine.home_dir = '/foo/bar'