19 declare(strict_types=1);
    46         foreach ($config as 
$key => $value) {
    48             if (
$key === 
'ignore_security_flaw') {
    50             } elseif (
$key === 
'data_directory') {
    61         return PHP_VERSION_ID >= 50307;
   109         if (!$this->client_salt) {
   117         return $this->
encode($raw, $salt);
   122         if (!$this->client_salt) {
   144     private function encode(
string $raw, 
string $userSecret): string
   147         $hashedPassword = hash_hmac(
   149             str_pad($raw, strlen($raw) * 4, sha1($userSecret), STR_PAD_BOTH),
   154             str_shuffle(str_repeat(
'./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 22)),
   168             if (!$this->is_security_flaw_ignored && preg_match(
'#[\x80-\xFF]#', $raw)) {
   170                     'The bcrypt implementation used by PHP can contain a security flaw ' .
   171                     'using passwords with 8-bit characters. ' .
   172                     'We suggest to upgrade to PHP 5.3.7+ or use passwords with only 7-bit characters.'   177         $saltedPassword = crypt($hashedPassword, $prefix . $this->
getCosts() . 
'$' . $salt);
   178         if (strlen($saltedPassword) <= 13) {
   182         return $saltedPassword;
   185     private function check(
string $encoded, 
string $raw, 
string $salt): bool
   187         $hashedPassword = hash_hmac(
   189             str_pad($raw, strlen($raw) * 4, sha1($salt), STR_PAD_BOTH),
   194         return $this->
comparePasswords($encoded, crypt($hashedPassword, substr($encoded, 0, 30)));
   199         return $this->data_directory . 
'/' . self::SALT_STORAGE_FILENAME;
   206             if ($contents !== 
false && trim($contents) !== 
'') {
   226         set_error_handler(
static function (
int $severity, 
string $message, 
string $file, 
int $line): never {
   227             throw new ErrorException($message, $severity, $severity, $file, $line);
   231             $result = file_put_contents(
$location, $this->client_salt);
   234                     'Could not store the client salt in: %s. Please contact an administrator.',
   240                 'Could not store the client salt in: %s. Please contact an administrator.',
   242             ), $e->getCode(), 
$e);
   244             restore_error_handler();
 const SALT_STORAGE_FILENAME
 
check(string $encoded, string $raw, string $salt)
 
setBackwardCompatibility(bool $backward_compatibility)
Set the backward compatibility $2a$ instead of $2y$ for PHP 5.3.7+. 
 
requiresSalt()
Returns whether the encoder requires a salt. 
 
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
isBackwardCompatibilityEnabled()
 
comparePasswords(string $knownString, string $userString)
Compares two passwords. 
 
setIsSecurityFlawIgnored(bool $is_security_flaw_ignored)
 
encodePassword(string $raw, string $salt)
Encodes the raw password. 
 
encode(string $raw, string $userSecret)
 
Class for user password exception handling in ILIAS. 
 
isPasswordTooLong(string $password)
 
bool $backward_compatibility
 
setDataDirectory(string $data_directory)
 
setClientSalt(?string $client_salt)
 
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback. 
 
requiresReencoding(string $encoded)
Returns whether the encoded password needs to be re-encoded. 
 
getName()
Returns a unique name/id of the concrete password encoder. 
 
bool $is_security_flaw_ignored
 
isPasswordValid(string $encoded, string $raw, string $salt)
Checks a raw password against an encoded password. 
 
__construct(array $config=[])