Ruby: Encrypting passwords for a database using one-way hash technique (SHA1)
Before you save a password to a database, it may make sense to encrypt it. That way, when you do some user authentication, you can compare the users submitted password to the one on the database.
#A. Import the SHA1 Method
require "digest/sha1"
#B. Encrypt the Password string
@hash_pass = Digest::SHA1.hexdigest('super password')
#C. Display the encrypted password
puts @hash_pass