7
我找不到一个如何做到这一点的例子。我有一个PGP加密的XLS文件和一个PGP密钥。这里的是我的代码,返回一个空字符串:如何用Ruby解密PGP加密文件gpgme
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
我能够解密该文件在一个名为使用相同的密钥在Windows GNU隐私助手程序。任何帮助表示赞赏。
感谢。有时我觉得GPGME的'E'代表'Enigmatic' – aidan 2014-09-22 04:16:11
@Vincent什么是obj,uid_hint,passphrase_info,prev_was_bad,fd参数。在我的情况下,客户端只共享公钥 - 私钥和加密文件 – VKatz 2018-02-22 06:59:27
@Vincent,请提供你的帮助我是一种沉溺!在之间。 – VKatz 2018-02-22 06:59:56