From: Jeremy Hinegardner Date: 2008-07-01T06:43:27+09:00 Subject: Re: Hiding a password in code. On Tue, Jul 01, 2008 at 05:04:12AM +0900, Dana Merrick wrote: > Leslie Viljoen wrote: >> Gnome solves this situation by using the Gnome login to open an >> encrypted keyring which stores passwords to things like Wireless >> networks. There should be a way for a Ruby program to leverage this >> functionality. > > While this would be cool, I don't use Gnome so unfortunately it would be > useless to me. I could, however, look into a Ruby API that works with OS > X's Keychain. That's a good idea and I'll look into it. I wrote keybox which is only requires ruby and ruby's openssl extension. It was initially for just storing my own passwords and making them avaialble from a console, but the Keybox::Storage::Container has a pretty simple API that could be utilized for this type of usage. You could use the command line to build the encrypted file and then in your code to something like: # app start # prompt for keybox password container = Keybox::Storage::Container.new( passphrase, "/path/to/keybox/file") # do long running stuff When the application needs the password it can do: record = container.find("record-key").first # do somethig with record.username and record.password Feel free to check it out and see if it would work for your situation. http://keybox.rubyforge.org/ http://keybox.rubyforge.org/rdoc/index.html enjoy, -jeremy -- ======================================================================== Jeremy Hinegardner jeremy@hinegardner.org