public function getHumanReadableName()
Return a human-readable description of this hasher, like "Iterated MD5".
string | Human readable hash name. |
public function getHashName()
Return a short, unique, key identifying this hasher, like "md5" or "bcrypt". This identifier should not be translated.
string | Short, unique hash name. |
public function getHashLength()
Return the maximum byte length of hashes produced by this hasher. This is used to prevent storage overflows.
int | Maximum number of bytes in hashes this class produces. |
public function canHashPasswords()
Return true to indicate that any required extensions or dependencies are available, and this hasher is able to perform hashing.
bool | True if this hasher can execute. |
public function getInstallInstructions()
Return a human-readable string describing why this hasher is unable to operate. For example, "To use bcrypt, upgrade to PHP 5.5.0 or newer.".
string | Human-readable description of how to enable this hasher. |
public function getStrength()
Return an indicator of this hasher's strength. When choosing to hash new passwords, the strongest available hasher which is usable for new passwords will be used, and the presence of a stronger hasher will prompt users to update their hashes.
Generally, this method should return a larger number than hashers it is preferable to, but a smaller number than hashers which are better than it is. This number does not need to correspond directly with the actual hash strength.
float | Strength of this hasher. |
public function getHumanReadableStrength()
Return a short human-readable indicator of this hasher's strength, like "Weak", "Okay", or "Good".
This is only used to help administrators make decisions about configuration.
string | Short human-readable description of hash strength. |
protected function getPasswordHash($envelope)
Produce a password hash.
PhutilOpaqueEnvelope | $envelope | Text to be hashed. |
PhutilOpaqueEnvelope | Hashed text. |
protected function verifyPassword($password, $hash)
Verify that a password matches a hash.
The default implementation checks for equality; if a hasher embeds salt in hashes it should override this method and perform a salt-aware comparison.
PhutilOpaqueEnvelope | $password | Password to compare. |
PhutilOpaqueEnvelope | $hash | Bare password hash. |
bool | True if the passwords match. |
protected function canUpgradeInternalHash($hash)
Check if an existing hash created by this algorithm is upgradeable.
The default implementation returns false. However, hash algorithms which have (for example) an internal cost function may be able to upgrade an existing hash to a stronger one with a higher cost.
PhutilOpaqueEnvelope | $hash | Bare hash. |
bool | True if the hash can be upgraded without changing the algorithm (for example, to a higher cost). |
final public function getPasswordHashForStorage($envelope)Inherited
Get the hash of a password for storage.
PhutilOpaqueEnvelope | $envelope | Password text. |
PhutilOpaqueEnvelope | Hashed text. |
private static function parseHashFromStorage($hash)Inherited
Parse a storage hash into its components, like the hash type and hash data.
PhutilOpaqueEnvelope | $hash |
map | Dictionary of information about the hash. |
public static function getAllHashers()Inherited
Get all available password hashers. This may include hashers which can not actually be used (for example, a required extension is missing).
list<PhabricatorPasswordHasher> | Hasher objects. |
public static function getAllUsableHashers()Inherited
Get all usable password hashers. This may include hashers which are not desirable or advisable.
list<PhabricatorPasswordHasher> | Hasher objects. |
public static function getBestHasher()Inherited
Get the best (strongest) available hasher.
PhabricatorPasswordHasher | Best hasher. |
public static function getHasherForHash($hash)Inherited
Get the hasher for a given stored hash.
PhutilOpaqueEnvelope | $hash |
PhabricatorPasswordHasher | Corresponding hasher. |
public static function canUpgradeHash($hash)Inherited
Test if a password is using an weaker hash than the strongest available hash. This can be used to prompt users to upgrade, or automatically upgrade on login.
PhutilOpaqueEnvelope | $hash |
bool | True to indicate that rehashing this password will improve the hash strength. |
public static function generateNewPasswordHash($password)Inherited
Generate a new hash for a password, using the best available hasher.
PhutilOpaqueEnvelope | $password | Password to hash. |
PhutilOpaqueEnvelope | Hashed password, using best available hasher. |
public static function comparePassword($password, $hash)Inherited
Compare a password to a stored hash.
PhutilOpaqueEnvelope | $password | Password to compare. |
PhutilOpaqueEnvelope | $hash | Stored password hash. |
bool | True if the passwords match. |
public static function getCurrentAlgorithmName($hash)Inherited
Get the human-readable algorithm name for a given hash.
PhutilOpaqueEnvelope | $hash | Storage hash. |
string | Human-readable algorithm name. |
public static function getBestAlgorithmName()Inherited
Get the human-readable algorithm name for the best available hash.
string | Human-readable name for best hash. |
private function getBcryptCost()
wild |