Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename Password#hash to #checksum to avoid conflicts with String#hash…

… (closes #1)
  • Loading branch information...
commit 5a2144616bcc45ad9a6f47e71869de922a822fa6 1 parent 374e18b
@tmm1 tmm1 authored
Showing with 5 additions and 3 deletions.
  1. +3 −3 lib/bcrypt.rb
  2. +2 −0  spec/bcrypt/password_spec.rb
View
6 lib/bcrypt.rb
@@ -133,7 +133,7 @@ def self.autodetect_cost(salt)
#
class Password < String
# The hash portion of the stored password hash.
- attr_reader :hash
+ attr_reader :checksum
# The salt of the store password hash (including version and cost).
attr_reader :salt
# The version of the bcrypt() algorithm used to create the hash.
@@ -160,7 +160,7 @@ def create(secret, options = { :cost => BCrypt::Engine::DEFAULT_COST })
def initialize(raw_hash)
if valid_hash?(raw_hash)
self.replace(raw_hash)
- @version, @cost, @salt, @hash = split_hash(self)
+ @version, @cost, @salt, @checksum = split_hash(self)
else
raise Errors::InvalidHash.new("invalid hash")
end
@@ -184,7 +184,7 @@ def valid_hash?(h)
# Splits +h+ into version, cost, salt, and hash and returns them in that order.
def split_hash(h)
b, v, c, mash = h.split('$')
- return v, c.to_i, h[0, 29].to_str, mash[-31, 31]
+ return v, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str
end
end
end
View
2  spec/bcrypt/password_spec.rb
@@ -40,6 +40,8 @@
password.cost.should equal(5)
password.salt.should eql("$2a$05$CCCCCCCCCCCCCCCCCCCCC.")
password.salt.class.should == String
+ password.checksum.should eq("E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW")
+ password.checksum.class.should == String
password.to_s.should eql(@hash)
end
Please sign in to comment.
Something went wrong with that request. Please try again.