Junkone
9/22/2008 3:01:00 PM
On Sep 22, 12:00 am, Justin Collins <justincoll...@ucla.edu> wrote:
> 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
i just store passwords in text files. i am looking for a secure way of
keeping these passwords and using it thro ruby as my progs need the
pass.
for eg. i send auto IM using bot and need my IM pass to be kept
secure.