Implementing a Hasher
- abstract public function getHumanReadableName() — Return a human-readable description of this hasher, like "Iterated MD5".
- abstract public function getHashName() — Return a short, unique, key identifying this hasher, like "md5" or "bcrypt". This identifier should not be translated.
- abstract public function getHashLength() — Return the maximum byte length of hashes produced by this hasher. This is used to prevent storage overflows.
- abstract public function canHashPasswords() — Return `true` to indicate that any required extensions or dependencies are available, and this hasher is able to perform hashing.
- abstract 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.".
- abstract 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.
- abstract public function getHumanReadableStrength() — Return a short human-readable indicator of this hasher's strength, like "Weak", "Okay", or "Good".
- abstract protected function getPasswordHash($envelope) — Produce a password hash.
- protected function verifyPassword($password, $hash) — Verify that a password matches a hash.
- protected function canUpgradeInternalHash($hash) — Check if an existing hash created by this algorithm is upgradeable.
Using Hashers
- final public function getPasswordHashForStorage($envelope) — Get the hash of a password for storage.
- private static function parseHashFromStorage($hash) — Parse a storage hash into its components, like the hash type and hash data.
- public static function getAllHashers() — Get all available password hashers. This may include hashers which can not actually be used (for example, a required extension is missing).
- public static function getAllUsableHashers() — Get all usable password hashers. This may include hashers which are not desirable or advisable.
- public static function getBestHasher() — Get the best (strongest) available hasher.
- public static function getHasherForHash($hash) — Get the hasher for a given stored hash.
- public static function canUpgradeHash($hash) — 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.
- public static function generateNewPasswordHash($password) — Generate a new hash for a password, using the best available hasher.
- public static function comparePassword($password, $hash) — Compare a password to a stored hash.
Other Methods
- public static function getCurrentAlgorithmName($hash) — Get the human-readable algorithm name for a given hash.
- public static function getBestAlgorithmName() — Get the human-readable algorithm name for the best available hash.