title: How can I asymmetrically encrypt data using OpenPGP with Ruby?
body: <p>This feels like it should be dead simple, yet I'm not having any luck.</p>
  
  <p>The scenario is this: I have a public *.asc key file. I want to use <em>this file</em> (not my personal keyring) to encrypt data on a server, so that I can decrypt it locally with a secret key.</p>
  
  <p>From the command line I can achieve this using <code>gpg</code>, but I'd prefer to use a Ruby library that isn't just a wrapper around the CLI (i.e., presumably one that provides bindings to the C library). I've looked at the GPGME and OpenPGP gems and haven't been able to figure out how to use them. The documentation (especially for OpenPGP) is quite sparse.</p>
  
  <p>Here, for example, is something I've tried using GPGME, without any luck:</p>
  
  <pre><code>key = GPGME::Data.new(File.open(path_to_file))
  data = GPGME::Data.new("I want to encrypt this string.")
  
  # Raises GPGME::Error::InvalidValue
  GPGME::Ctx.new do |ctx|
    e = ctx.encrypt(key, data)
  end
  </code></pre>
  
  <p>Has anyone been through this already? Surely this can't be that complicated?</p>