From: Justin Collins Date: 2008-09-22T13:00:09+09:00 Subject: Re: how to manage passwords Junkone wrote: > many of my ruby apps have the password hard coded. i am looking for a > way so that i can control the password not to be stored as text file. > what are the ruby options that are available. > Do you need to know what the stored password is, or do you just need to validate passwords? If the latter, you can use the MD5, SHA1, or SHA2 libraries that come with Ruby: require 'digest/sha1' #Could load the hash from a file instead hash = Digest::SHA1.new.update("mypassword") print "Enter password: " input_password = gets.strip if hash == Digest::SHA1.new.update(input_password) puts "Access granted." else puts "Access denied." end -Justin