Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypt the file using public key only #111

Open
brijeshgpt7 opened this issue Feb 22, 2018 · 1 comment
Open

Decrypt the file using public key only #111

brijeshgpt7 opened this issue Feb 22, 2018 · 1 comment

Comments

@brijeshgpt7
Copy link

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)

@ueno
Copy link
Owner

ueno commented Feb 26, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants