class Password (View source)

The SimplePassword class.

Constants

MD5

BLOWFISH

SHA256

SHA512

Methods

__construct(int $type = self::BLOWFISH, int $cost = 10, string $salt = null)

Constructor.

string
create(string $password)

create

boolean
verify(string $password, string $hash)

Verify the password.

static string
genRandomPassword(integer $length = 8)

Generate a random password.

string
getSalt()

Method to get property Salt

setSalt(string $salt)

Method to set property salt

int
getCost()

Method to get property Cost

setCost(int $cost)

Method to set property cost

int
getType()

Method to get property Type

setType(int $type)

Method to set property type

Details

at line line 54
__construct(int $type = self::BLOWFISH, int $cost = 10, string $salt = null)

Constructor.

Parameters

int $type
int $cost
string $salt

at line line 68
string create(string $password)

create

Parameters

string $password

Return Value

string

at line line 131
boolean verify(string $password, string $hash)

Verify the password.

Parameters

string $password The password plain text.
string $hash The hashed password.

Return Value

boolean Verify success or not.

See also

https://github.com/ircmaxell/password_compat/blob/92951ae05e988803fdc1cd49f7e4cd29ca7b75e9/lib/password.php#L230-L247

at line line 182
static string genRandomPassword(integer $length = 8)

Generate a random password.

This is a fork of Joomla JUserHelper::genRandomPassword()

Parameters

integer $length Length of the password to generate

Return Value

string Random Password

See also

https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/user/helper.php#L642

at line line 213
string getSalt()

Method to get property Salt

Return Value

string

at line line 225
Password setSalt(string $salt)

Method to set property salt

Parameters

string $salt

Return Value

Password Return self to support chaining.

at line line 237
int getCost()

Method to get property Cost

Return Value

int

at line line 250
Password setCost(int $cost)

Method to set property cost

Parameters

int $cost

Return Value

Password Return self to support chaining.

Exceptions

InvalidArgumentException

at line line 262
int getType()

Method to get property Type

Return Value

int

at line line 274
Password setType(int $type)

Method to set property type

Parameters

int $type

Return Value

Password Return self to support chaining.