Permalink
Browse files

Updated encryption

  • Loading branch information...
1 parent 6c8f420 commit 08b848f5e65b1f61cb65c0dfe68d495d245347c7 @alg alg committed Sep 15, 2010
Showing with 3 additions and 1 deletion.
  1. +1 −1 app/models/ballot.rb
  2. +2 −0 lib/paperclip_processors/encrypt.rb
View
@@ -6,7 +6,7 @@ class Ballot < ActiveRecord::Base
has_attached_file :pdf, :path => ':rails_root/ballots/:id.pdf.gpg',
:url => '/', # Disallow external access
- :styles => { :encrypt => AppConfig['gpg_recipient'] },
+ :styles => { :original => AppConfig['gpg_recipient'] },
:processors => [ :encrypt ]
validates_presence_of :registration_id, :on => :create
@@ -15,6 +15,8 @@ def make
dst = Tempfile.new([@basename, 'gpg'].compact.join("."))
dst.binmode
+ raise PaperclipError, "GPG recipient wasn't set" if @recipient.blank?
+
`rm -f "#{File.expand_path(dst.path)}"; gpg -o "#{File.expand_path(dst.path)}" -e -r "#{@recipient}" "#{File.expand_path(src.path)}"`
dst

0 comments on commit 08b848f

Please sign in to comment.