RDoc Documentation

File: README.rdoc

Path:README.rdoc
Modified:Thu Aug 12 21:17:47 -0400 2010

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 => "[email protected]", :password => "asdf")
   user.password #=> "$2a$10$0DvrQ.HMKRySMJrn0cGEM.AcesF82tkeBfNLTZTZ.VSWePihZD3mG"
   user.password == "asdf" # => true

   # works with updating fields also
   user = User.find_by_email("[email protected]")
   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

Copyright (c) 2010 Kevin Swope. See LICENSE for details.

Classes

Files: 1 Classes: 0 Modules: 0 Methods: 0 Elapsed: 0.044s