diff --git a/spec/std/crypto/bcrypt/password_spec.cr b/spec/std/crypto/bcrypt/password_spec.cr index 269ab140c421..4e2a3faa1ac9 100644 --- a/spec/std/crypto/bcrypt/password_spec.cr +++ b/spec/std/crypto/bcrypt/password_spec.cr @@ -78,4 +78,13 @@ describe "Crypto::Bcrypt::Password" do (password2y.verify "secret").should be_true end end + + describe "#==" do + it "is equal if the string representations are equal" do + canonical = Crypto::Bcrypt::Password.create("secret", 4) + challenge = Crypto::Bcrypt::Password.new(canonical.to_s) + + canonical.should eq challenge + end + end end diff --git a/src/crypto/bcrypt/password.cr b/src/crypto/bcrypt/password.cr index b98658c9e22f..77da2810d998 100644 --- a/src/crypto/bcrypt/password.cr +++ b/src/crypto/bcrypt/password.cr @@ -83,4 +83,6 @@ class Crypto::Bcrypt::Password def inspect(io : IO) : Nil to_s(io) end + + def_equals_and_hash end