Module: ClearanceCrypto::BCrypt::InstanceMethods

Defined in:
lib/clearance_crypto/bcrypt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#costObject



10
11
12
# File 'lib/clearance_crypto/bcrypt.rb', line 10

def cost
  @cost ||= 10
end

Instance Method Details

#authenticated?(string) ⇒ Boolean

Does the hash match the tokens? Uses the same tokens that were used to encrypt.

Returns:

  • (Boolean)


21
22
23
# File 'lib/clearance_crypto/bcrypt.rb', line 21

def authenticated?(string)
  ::BCrypt::Password.new(self.encrypted_password) == "--#{salt}--#{string}--" rescue false
end

#encrypt(string) ⇒ Object

Creates a BCrypt hash for the password passed.



16
17
18
# File 'lib/clearance_crypto/bcrypt.rb', line 16

def encrypt(string)
  ::BCrypt::Password.create("--#{salt}--#{string}--")
end