Top Level Namespace

Defined Under Namespace

Classes: CryptCheckpass

Instance Method Summary collapse

Instance Method Details

#crypt_checkpass?(pass, hash) ⇒ true, false

Parses what the given hash is, apply the same hashing against pass, then compares the hashed pass and the given hash.

Parameters:

  • pass (String)

    password string.

  • hash (String)

    hashed string.

Returns:

  • (true)

    they are identical.

  • (false)

    they are distinct.

Raises:

  • (NotImplementedError)

    don't know how to parse hash.



34
35
36
# File 'lib/crypt_checkpass.rb', line 34

def crypt_checkpass? pass, hash
  return CryptCheckpass::crypt_checkpass? pass, hash
end

#crypt_newhash(password, perf) ⇒ String #crypt_newhash(password, id: , **kwargs) ⇒ String

Generates new password hashes. The provided password is randomly salted, then hashed using the parameter.

Overloads:

  • #crypt_newhash(password, perf) ⇒ String
    Note:

    This usage is for OpenBSD fans.

    The pref argument identifies the preferred hashing algorithm and parameters. Possible values are:

    • "bcrypt,<rounds>"
    • "blowfish,<rounds>"

    where "rounds" can be a number between 4 and 31, or "a" for default.

    Parameters:

    • password (String)

      bare, unhashed binary password.

    • pref (String)

      algorithm preference specifier.

    Returns:

    • (String)

      hashed digest string of password.

    Raises:

    • (NotImplementedError)

      pref not understandable.

    See Also:

  • #crypt_newhash(password, id: , **kwargs) ⇒ String

    At least :id argument must be provided this case, which is the name of key derivation function (the ID that the PHC string format says).

    Parameters:

    • password (String)

      bare, unhashed binary password.

    • id (String) (defaults to: )

      name of the function.

    • kwargs (Symbol=>String, Integer)

      passed to the KDF.

    Returns:

    • (String)

      hashed digest string of password.

    Raises:

    • (NotImplementedError)

      unknown KDF is specified.



66
67
68
# File 'lib/crypt_checkpass.rb', line 66

def crypt_newhash password, pref = nil, id: nil, **kwargs
  return CryptCheckpass::crypt_newhash password, pref, id: id, **kwargs
end