I copied Ryan Bate's concepts on creating a password salt and hash. You can find the code in his Nifty Generators for rails.