Method: BCrypt::Password#==
- Defined in:
- lib/bcrypt/password.rb
#==(secret) ⇒ Object Also known as: is_password?
Compares a potential secret against the hash. Returns true if the secret is the original secret, false otherwise.
Comparison edge case/gotcha:
secret = "my secret"
@password = BCrypt::Password.create(secret)
@password == secret # => True
@password == @password # => False
@password == @password.to_s # => False
@password.to_s == @password # => True
@password.to_s == @password.to_s # => True
76 77 78 |
# File 'lib/bcrypt/password.rb', line 76 def ==(secret) super(BCrypt::Engine.hash_secret(secret, @salt)) end |