Plugin for GnuPG on Ruby on Rails
October 10th, 2007
GnuPG plugin for ruby on rails! The README in the plugin has all the basic usage info. Its fairly easy to use. The hardest part, by far, is setting up your environment to use GnuPG for web-applications (permissions, security, all that jazz).
Get it here
./script/plugin install svn://ahgsoftware.com/gnupg/trunk |
Example (assuming you have 'private key' imported into workdir)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# We're using the same workdir for pub and sec, they could differ! workdir = File.join(RAILS_ROOT,"tmp","gnupg") passphrase = "uglydonkeys" # This is a darwin-ports on Mac OS X version of gpg gnupg = GnuPG.new :binary=>"/opt/local/bin/gpg", :workdir=>workdir, :homedir_pub=>workdir, :homedir_sec=>workdir, :recipient=>"your uid" plain_message = "no more mustachoed tyrants, muhwahwahwa, buhwahwahwa" encrypted_message = gnupg.encrypt(plain_message) # Load ascii sec key, from wherever you might have it gnupg.load_key File.read("sec_key.asc") decrypted_message = gnupg.decrypt(encrypted_message, passphrase) gnupg.drop_key puts plain_message puts encrypted_message puts decrypted_message |
Leave a Reply