Skip to content

Instantly share code, notes, and snippets.

@jmileham
Created September 14, 2011 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmileham/1217668 to your computer and use it in GitHub Desktop.
Save jmileham/1217668 to your computer and use it in GitHub Desktop.
Minimal GPG Paperclip processor
# You'll need to pregenerate a keyring with your pubkey in it and add to your repo.
# GPG does this automatically when you import keys to a non-existant keyring file.
module Paperclip
class Encrypt < Processor
def make
raise ArgumentError.new("no :encrypt_to address provided. (#{@options.inspect})") unless @options[:encrypt_to]
Tempfile.new(['attachment','.pgp']).tap do |outfile|
Paperclip.run('gpg', '--batch --always-trust --keyring :keyring --no-default-keyring -o :out -r :recipient -e :in', :in => @file.path, :out => outfile.path, :recipient => @options[:encrypt_to], :keyring => PATH_TO_MY_KEYRING)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment