class Object
Public Instance Methods
crypt_checkpass?(pass, hash)
click to toggle source
Parses what the given hash is, apply the same hashing against pass, then compares the hashed pass and the given hash.
@param pass [String] password string. @param hash [String] hashed string. @return [true] they are identical. @return [false] they are distinct. @raise [NotImplementedError] don't know how to parse hash.
# File lib/crypt_checkpass.rb, line 34 def crypt_checkpass? pass, hash return CryptCheckpass::crypt_checkpass? pass, hash end
crypt_newhash(password, pref = nil, id: nil, **kwargs)
click to toggle source
Generates new password hashes. The provided password is randomly salted, then hashed using the parameter.
@overload crypt_newhash
(password, perf)
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. @note This usage is for OpenBSD fans. @see https://man.openbsd.org/crypt_newhash.3 crypt_newhash(3) @param password [String] bare, unhashed binary password. @param pref [String] algorithm preference specifier. @raise [NotImplementedError] pref not understandable. @return [String] hashed digest string of password.
@overload crypt_newhash
(password, id:, **kwargs)
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). @param password [String] bare, unhashed binary password. @param id [String] name of the function. @param kwargs [Symbol=>String,Integer] passed to the KDF. @return [String] hashed digest string of password. @raise [NotImplementedError] unknown KDF is specified.
# 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