diff --git a/lib/bcrypt/password.rb b/lib/bcrypt/password.rb index ab7c46d..fd19b47 100644 --- a/lib/bcrypt/password.rb +++ b/lib/bcrypt/password.rb @@ -80,7 +80,7 @@ def valid_hash?(h) # Splits +h+ into version, cost, salt, and hash and returns them in that order. def split_hash(h) _, v, c, mash = h.split('$') - return v, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str + return v.to_str, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str end end diff --git a/spec/bcrypt/password_spec.rb b/spec/bcrypt/password_spec.rb index 4b2e6c7..648e614 100644 --- a/spec/bcrypt/password_spec.rb +++ b/spec/bcrypt/password_spec.rb @@ -75,6 +75,7 @@ specify "should read the version, cost, salt, and hash" do password = BCrypt::Password.new(@hash) expect(password.version).to eql("2a") + expect(password.version.class).to eq String expect(password.cost).to equal(5) expect(password.salt).to eql("$2a$05$CCCCCCCCCCCCCCCCCCCCC.") expect(password.salt.class).to eq String