Posted By

chrisaiv on 10/21/07


Tagged

ruby SHA1 encyption


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Encrypting passwords for a database using one-way hash technique (SHA1)


 / Published in: Ruby
 

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.

  1. #A. Import the SHA1 Method
  2. require "digest/sha1"
  3. #B. Encrypt the Password string
  4. @hash_pass = Digest::SHA1.hexdigest('super password')
  5. #C. Display the encrypted password
  6. puts @hash_pass

Report this snippet  

You need to login to post a comment.