class PasswordEncryptor

Allows pluggable password encryption.

By default, this might be PHP's integrated sha1() function, but could also be more sophisticated to facilitate password migrations from other systems. Use {@link register()} to add new implementations.

Used in {@link Security::encrypt_password()}.

Config options

encryptors array

Methods

static array
get_encryptors()

No description

create_for_algorithm(String $algorithm)

No description

String
encrypt(String $password, String $salt = null, Member $member = null)

Return a string value stored in the {@link Member->Password} property.

string
salt(string $password, Member $member = null)

Return a string value stored in the {@link Member->Salt} property.

bool
check(string $hash, string $password, string $salt = null, Member $member = null)

This usually just returns a strict string comparison, but is necessary for retain compatibility with password hashed with flawed algorithms - see {@link PasswordEncryptor_LegacyPHPHash} and {@link PasswordEncryptor_Blowfish}

Details

at line 29
static array get_encryptors()

Return Value

array Map of encryptor code to the used class.

at line 39
static PasswordEncryptor create_for_algorithm(String $algorithm)

Parameters

String $algorithm

Return Value

PasswordEncryptor

Exceptions

PasswordEncryptor_NotFoundException

at line 72
abstract String encrypt(String $password, String $salt = null, Member $member = null)

Return a string value stored in the {@link Member->Password} property.

The password should be hashed with {@link salt()} if applicable.

Parameters

String $password Cleartext password to be hashed
String $salt (Optional)
Member $member (Optional)

Return Value

String Maximum of 512 characters.

at line 83
string salt(string $password, Member $member = null)

Return a string value stored in the {@link Member->Salt} property.

Parameters

string $password Cleartext password
Member $member (Optional)

Return Value

string Maximum of 50 characters

at line 101
bool check(string $hash, string $password, string $salt = null, Member $member = null)

This usually just returns a strict string comparison, but is necessary for retain compatibility with password hashed with flawed algorithms - see {@link PasswordEncryptor_LegacyPHPHash} and {@link PasswordEncryptor_Blowfish}

Parameters

string $hash
string $password
string $salt
Member $member

Return Value

bool