Project

auto_hash

0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby on Rails plugin to automate hashing an activerecord field using bcrypt; an activerecord wrapper for bcrypt-ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

auto_hash¶ ↑

A Ruby on Rails plugin to automate the cryptographic hashing of an activerecord field.

UPDATE: auto_hash has quickly evolved to be a activerecord plugin that merely wraps the excellent bcrypt-ruby library. bcrypt-ruby.rubyforge.org

Works with both rails 2x and 3x

WARNING: untested with ruby 1.9.2 at the moment. (Couldn’t get rails 3x to work with ruby 1.9.2 - too early I guess)

Synopsis¶ ↑

# In Model
class User < ActiveRecord::Base
  auto_hash :password
end

# Elsewhere
user = User.create(:email => "kevin@example.com", :password => "asdf")
user.password #=> "$2a$10$0DvrQ.HMKRySMJrn0cGEM.AcesF82tkeBfNLTZTZ.VSWePihZD3mG"
user.password == "asdf" # => true

# works with updating fields also
user = User.find_by_email("kevin@example.com")
user.password = "better_password"
user.password == "better_password" # => true

Rails configuration (nothing unusual)¶ ↑

For rails 2x, in environment.rb

Rails::Initializer.run do |config| do
  config.gem "auto_hash"
end

For rails 3x, in Gemfile

gem "auto_hash"

Copyright © 2010 Kevin Swope. See LICENSE for details.