Go to the documentation of this file.
23 use Wikimedia\Assert\Assert;
98 throw new Exception(
'PHP support not found for ' . get_class( $this ) );
100 if ( !isset(
$config[
'type'] ) ) {
101 throw new Exception(
'Password configuration must contain a type name.' );
106 if (
$hash !==
null && strlen(
$hash ) >= 3 ) {
121 return $this->config[
'type'];
166 if ( is_string( $other ) ) {
167 return $this->
verify( $other );
170 return hash_equals( $this->
toString(), $other->toString() );
180 Assert::parameterType(
'string', $password,
'$password' );
185 $obj->crypt( $password );
187 return hash_equals( $this->
toString(), $obj->toString() );
203 $result =
':' . $this->config[
'type'] .
':' .
$this->hash;
219 if ( strlen(
$hash ) > self::MAX_HASH_SIZE ) {
233 abstract public function crypt( $password );
equals( $other)
Compare one Password object to this object.
Show an error when any operation involving passwords fails to run.
array $config
Array of configuration variables injected from the constructor.
assertIsSafeSize( $hash)
Assert that hash will fit in a tinyblob field.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
isSupported()
Whether current password type is supported on this system.
crypt( $password)
Hash a password and store the result in this object.
const MAX_HASH_SIZE
Hash must fit in user_password, which is a tinyblob.
getType()
Get the type name of the password.
toString()
Convert this hash to a string that can be stored in the database.
__construct(PasswordFactory $factory, array $config, $hash=null)
Construct the Password object using a string hash.
string $hash
String representation of the hash without the type.
verify( $password)
Checks whether the given password matches the hash stored in this object.
parseHash( $hash)
Perform any parsing necessary on the hash to see if the hash is valid and/or to perform logic for see...
needsUpdate()
Determine if the hash needs to be updated.
PasswordFactory $factory
Factory that created the object.
Factory class for creating and checking Password objects.
Represents a password hash for use in authentication.