Skip to content

Instantly share code, notes, and snippets.

@namelessjon
Created January 27, 2011 21:36
Show Gist options
  • Save namelessjon/799333 to your computer and use it in GitHub Desktop.
Save namelessjon/799333 to your computer and use it in GitHub Desktop.
Example showing the use of the bcrypt password api
class User
def self.authenticate(email, password)
user = find_by_email(email)
if user && BCrypt::Password.new(user.password_hash) == password
user
else
nil
end
end
def encrypt_password
if password.present?
self.password_hash = BCrypt::Password.create(password)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment