class DeviseMeteor::Hasher

Attributes

algorithm[R]

Public Instance Methods

encode(password, salt) click to toggle source

Returns given password encoded with the given salt.

@param [String] password in plain text @param [String] salt to be used during hashing @return [String] given password hashed using the given salt

# File lib/devise_meteor/strategies/hasher.rb, line 30
def encode(password, salt)
  raise NotImplementedError
end
must_update(encoded) click to toggle source

Returns if given encoded password needs to be updated.

@param [String] encoded password @return [Boolean] if encoded password needs to be updated

# File lib/devise_meteor/strategies/hasher.rb, line 38
def must_update(encoded)
  false
end
salt() click to toggle source

Returns salt value to be used for hashing.

@return [String] random salt value.

# File lib/devise_meteor/strategies/hasher.rb, line 12
def salt
  SecureRandom.hex(9)
end
verify(password, encoded) click to toggle source

Returns if the given password match the encoded password.

@param [String] password in plain text @param [String] encoded password to be matched @return [Boolean] if password match encoded password.

# File lib/devise_meteor/strategies/hasher.rb, line 21
def verify(password, encoded)
  raise NotImplementedError
end

Private Instance Methods

constant_time_compare(a, b) click to toggle source
# File lib/devise_meteor/strategies/hasher.rb, line 44
def constant_time_compare(a, b)
  check = a.bytesize ^ b.bytesize
  a.bytes.zip(b.bytes) { |x, y| check |= x ^ y }
  check == 0
end