diff --git a/lib/authlogic/crypto_providers/bcrypt.rb b/lib/authlogic/crypto_providers/bcrypt.rb index 5811d7c1..b8eb4856 100644 --- a/lib/authlogic/crypto_providers/bcrypt.rb +++ b/lib/authlogic/crypto_providers/bcrypt.rb @@ -1,8 +1,4 @@ -begin - require "bcrypt" -rescue LoadError - "sudo gem install bcrypt-ruby" -end +require "bcrypt" module Authlogic module CryptoProviders @@ -55,19 +51,19 @@ def cost @cost ||= 10 end attr_writer :cost - + # Creates a BCrypt hash for the password passed. def encrypt(*tokens) ::BCrypt::Password.create(join_tokens(tokens), :cost => cost) end - + # Does the hash match the tokens? Uses the same tokens that were used to encrypt. def matches?(hash, *tokens) hash = new_from_hash(hash) return false if hash.blank? hash == join_tokens(tokens) end - + # This method is used as a flag to tell Authlogic to "resave" the password upon a successful login, using the new cost def cost_matches?(hash) hash = new_from_hash(hash) @@ -77,12 +73,12 @@ def cost_matches?(hash) hash.cost == cost end end - + private def join_tokens(tokens) tokens.flatten.join end - + def new_from_hash(hash) begin ::BCrypt::Password.new(hash) diff --git a/lib/authlogic/crypto_providers/scrypt.rb b/lib/authlogic/crypto_providers/scrypt.rb index 3721c284..e1e9400b 100644 --- a/lib/authlogic/crypto_providers/scrypt.rb +++ b/lib/authlogic/crypto_providers/scrypt.rb @@ -1,8 +1,4 @@ -begin - require "scrypt" -rescue LoadError - "sudo gem install scrypt" -end +require "scrypt" module Authlogic module CryptoProviders @@ -67,7 +63,7 @@ def matches?(hash, *tokens) def join_tokens(tokens) tokens.flatten.join end - + def new_from_hash(hash) begin ::SCrypt::Password.new(hash)