Fuller error message for invalid hashes #50

Closed
wants to merge 2 commits into from

2 participants

@jabley

No description provided.

@tmm1 tmm1 commented on the diff Mar 31, 2013
spec/bcrypt/password_spec.rb
@@ -15,6 +15,10 @@
lambda { BCrypt::Password.new(@password) }.should_not raise_error
end
+ specify "should raise an InvalidHash error if the hash is invalid" do
+ lambda { BCrypt::Password.new("79V5biR6fOmJzqDKO4PScOmtVpY=") }.should raise_error(BCrypt::Errors::InvalidHash)
+ end
+
@tmm1
Collaborator
tmm1 added a note Mar 31, 2013

There's already a test for this in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tmm1 tmm1 commented on the diff Mar 31, 2013
lib/bcrypt.rb
@@ -164,7 +164,7 @@ def initialize(raw_hash)
self.replace(raw_hash)
@version, @cost, @salt, @checksum = split_hash(self)
else
- raise Errors::InvalidHash.new("invalid hash")
+ raise Errors::InvalidHash.new("invalid hash: <#{raw_hash}>")
@tmm1
Collaborator
tmm1 added a note Mar 31, 2013

Why is this useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tmm1 tmm1 closed this May 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment