#!/usr/bin/env ruby require 'gpgme' ctx = GPGME::GpgmeCtx.new passphrase_cb = proc do |h,d,r| if d STDERR.puts(d) begin system('stty -echo') gets.chomp ensure system('stty echo') end end end ctx.set_passphrase_cb(passphrase_cb) plain = GPGME::GpgmeData.new plain.write('test test test') signed = ctx.sign(plain, GPGME::GPGME_SIG_MODE_CLEAR) puts("#{signed.read}")