MediaWiki
1.34.0
MWSaltedPassword.php
Go to the documentation of this file.
1
<?php
30
class
MWSaltedPassword
extends
ParameterizedPassword
{
31
protected
function
getDefaultParams
() {
32
return
[];
33
}
34
35
protected
function
getDelimiter
() {
36
return
':'
;
37
}
38
39
public
function
crypt
( $plaintext ) {
40
if
( count( $this->args ) == 0 ) {
41
$this->args[] =
MWCryptRand::generateHex
( 8 );
42
}
43
44
$this->hash = md5( $this->args[0] .
'-'
. md5( $plaintext ) );
45
46
if
( !is_string( $this->hash ) || strlen( $this->hash ) < 32 ) {
47
throw
new
PasswordError
(
'Error when hashing password.'
);
48
}
49
}
50
}
MWSaltedPassword\getDelimiter
getDelimiter()
Returns the delimiter for the parameters inside the hash.
Definition:
MWSaltedPassword.php:35
PasswordError
Show an error when any operation involving passwords fails to run.
Definition:
PasswordError.php:26
MWSaltedPassword\getDefaultParams
getDefaultParams()
Return an ordered array of default parameters for this password hash.
Definition:
MWSaltedPassword.php:31
MWSaltedPassword\crypt
crypt( $plaintext)
Hash a password and store the result in this object.
Definition:
MWSaltedPassword.php:39
MWSaltedPassword
The old style of MediaWiki password hashing, with a salt.
Definition:
MWSaltedPassword.php:30
MWCryptRand\generateHex
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
Definition:
MWCryptRand.php:36
ParameterizedPassword
Helper class for password hash types that have a delimited set of parameters inside of the hash.
Definition:
ParameterizedPassword.php:38
includes
password
MWSaltedPassword.php
Generated on Thu Dec 19 2019 14:54:42 for MediaWiki by
1.8.16