Decrypt the file using public key only
I have an encrypted file with pgp extension that needs to be decrypted using the shared public key. `require 'rubygems' require 'gpgme'
def passfunc(obj, uid_hint, passphrase_info, prev_was_bad, fd) io = IO.for_fd(fd, 'w') io.puts "PASSPHRASE" io.flush end
encrypted_data = GPGME::Data.new(File.open("file.xls.pgp")) key = GPGME::Data.new(File.open("key.txt"))
ctx = GPGME::Ctx.new :passphrase_callback => method(:passfunc) ctx.import_keys key
decrypted = ctx.decrypt encrypted_data
puts decrypted.read`
Error: r/gems/gpgme-2.0.11/lib/gpgme/ctx.rb:385:in `import_keys': Unsupported protocol (GPGME::Error)
While the error message looks interesting, I don't get what you want to achieve. In public key cryptography, you can't decrypt message with a public key.