class SecureArchive::Encryptor::Gpg

Public Class Methods

new(recipients) click to toggle source
# File lib/secure_archive/encryptor/gpg.rb, line 9
def initialize(recipients)
  @crypto = GPGME::Crypto.new
  recipients.each do |recipient|
    if GPGME::Key.find(:public, recipient).count == 0 then
      raise RecipientNotInKeyring, "Recipient #{recipient} does not exist in keyring"
    end
  end
  @recipients = recipients
end

Public Instance Methods

encrypt_file(source, destination) click to toggle source
# File lib/secure_archive/encryptor/gpg.rb, line 19
def encrypt_file(source, destination)
  File.open(destination, 'w') do |w|
    @crypto.encrypt(File.open(source), recipients: @recipients, output: w, always_trust: true)
  end
end