From: Daiki Ueno Date: 2010-01-17T22:19:33+09:00 Subject: Re: GPGME gem - cannot figure out how to decrypt data --=-=-= Daiki Ueno writes: > Could you try the attached script, which decrypts a file specified as > the first command line argument? Sorry, I mistakenly posted a wrong script. Please use this one instead... --=-=-= Content-Type: application/x-ruby Content-Disposition: attachment; filename=decrypt.rb #!/usr/bin/env ruby require 'gpgme' # If you do not have gpg-agent installed, comment out the following # and set it as :passphrase_callback. # def passfunc(hook, uid_hint, passphrase_info, prev_was_bad, fd) $stderr.write("Passphrase for #{uid_hint}: ") $stderr.flush begin system('stty -echo') io = IO.for_fd(fd, 'w') io.puts($stdin.gets) io.flush ensure (0 ... $_.length).each do |i| $_[i] = ?0 end if $_ system('stty echo') end $stderr.puts end plain = GPGME::decrypt(ARGF, { :passphrase_callback => method(:passfunc) }) puts("Plaintext:\n#{plain}") --=-=-= Don't forget to do "unset GPG_AGENT_INFO" before running it, to let GPGME ignore gpg-agent. Regards, -- Daiki Ueno --=-=-=--