зеркало из https://github.com/github/ruby-gpgme.git
Make examples workable with 2.0 API.
This commit is contained in:
Родитель
638887772d
Коммит
c8fb1bab83
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'gpgme'
|
||||
|
||||
GPGME.list_keys(ARGV.shift) do |key|
|
||||
ctx = GPGME::Ctx.new
|
||||
ctx.each_key(ARGV.shift) do |key|
|
||||
puts(key)
|
||||
end
|
||||
|
|
|
@ -28,12 +28,15 @@ plain = 'test test test'
|
|||
puts("Plaintext:\n#{plain}")
|
||||
|
||||
# Perform symmetric encryption on PLAIN.
|
||||
cipher = GPGME::encrypt(nil, plain, {:armor => true,
|
||||
crypto = GPGME::Crypto.new(:armor => true)
|
||||
cipher = crypto.encrypt(plain, {:symmetric => true,
|
||||
# :passphrase_callback => method(:passfunc)
|
||||
})
|
||||
puts("Ciphertext:\n#{cipher}")
|
||||
str = cipher.read
|
||||
puts("Ciphertext:\n#{str}")
|
||||
|
||||
plain = GPGME::decrypt(cipher, {
|
||||
cipher = GPGME::Data.new(str)
|
||||
plain = crypto.decrypt(cipher, {
|
||||
# :passphrase_callback => method(:passfunc)
|
||||
})
|
||||
puts("Plaintext:\n#{plain}")
|
||||
puts("Plaintext:\n#{plain.read}")
|
||||
|
|
|
@ -24,6 +24,8 @@ unless ENV['GPG_AGENT_INFO']
|
|||
exit(1)
|
||||
end
|
||||
|
||||
puts GPGME::clearsign('test test test', {
|
||||
# :passphrase_callback => method(:passfunc)
|
||||
})
|
||||
crypto = GPGME::Crypto.new
|
||||
signature = crypto.clearsign('test test test', {
|
||||
# :passphrase_callback => method(:passfunc)
|
||||
})
|
||||
puts signature.read
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'gpgme'
|
||||
|
||||
GPGME::verify(ARGF.read, nil, $stdout) do |signature|
|
||||
puts(signature.to_s)
|
||||
crypto = GPGME::Crypto.new
|
||||
signature = GPGME::Data.new(ARGF.read)
|
||||
crypto.verify(signature) do |sig|
|
||||
puts(sig.to_s)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче