Class: DeviseMeteor::Hasher

Inherits:
Object
  • Object
show all
Defined in:
lib/devise_meteor/strategies/hasher.rb

Direct Known Subclasses

BCryptSHA256Hasher

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#algorithmObject (readonly)

Returns the value of attribute algorithm.



7
8
9
# File 'lib/devise_meteor/strategies/hasher.rb', line 7

def algorithm
  @algorithm
end

Instance Method Details

#encode(password, salt) ⇒ String

Returns given password encoded with the given salt.

Parameters:

  • password (String)

    in plain text

  • salt (String)

    to be used during hashing

Returns:

  • (String)

    given password hashed using the given salt

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/devise_meteor/strategies/hasher.rb', line 30

def encode(password, salt)
  raise NotImplementedError
end

#must_update(encoded) ⇒ Boolean

Returns if given encoded password needs to be updated.

Parameters:

  • encoded (String)

    password

Returns:

  • (Boolean)

    if encoded password needs to be updated



38
39
40
# File 'lib/devise_meteor/strategies/hasher.rb', line 38

def must_update(encoded)
  false
end

#saltString

Returns salt value to be used for hashing.

Returns:

  • (String)

    random salt value.



12
13
14
# File 'lib/devise_meteor/strategies/hasher.rb', line 12

def salt
  SecureRandom.hex(9)
end

#verify(password, encoded) ⇒ Boolean

Returns if the given password match the encoded password.

Parameters:

  • password (String)

    in plain text

  • encoded (String)

    password to be matched

Returns:

  • (Boolean)

    if password match encoded password.

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/devise_meteor/strategies/hasher.rb', line 21

def verify(password, encoded)
  raise NotImplementedError
end