/** * Checks if a password is strong enough for use on a live site. Used to check the front-end Secret Word. * * @param string $password The password to check * @param bool $throwExceptions Throw an exception if the password is not strong enough? * * @return bool */ public static function isStrongEnough($password, $throwExceptions = true) { $complexify = new self(); $res = $complexify->evaluateSecurity($password); if ($res->valid) { return true; } if (!$throwExceptions) { return false; } $error = count($res->errors) ? array_shift($res->errors) : 'toosimple'; $errorMessage = Platform::getInstance()->translate('COM_AKEEBA_CPANEL_ERR_FESECRETWORD_' . $error); throw new \RuntimeException($errorMessage, 403); }
/** * Checks if a password is strong enough for use on a live site. Used to check the front-end Secret Word. * * @param string $password The password to check * @param bool $throwExceptions Throw an exception if the password is not strong enough? * * @return bool */ public static function isStrongEnough($password, $throwExceptions = true) { $complexify = new self(); $res = (object) array('valid' => strlen($password) >= 32, 'complexity' => 50, 'errors' => strlen($password) >= 32 ? array() : array('tooshort')); if (function_exists('mb_strlen') && function_exists('mb_convert_encoding') && function_exists('mb_substr') && function_exists('mb_convert_case')) { $res = $complexify->evaluateSecurity($password); } if ($res->valid) { return true; } if (!$throwExceptions) { return false; } $error = count($res->errors) ? array_shift($res->errors) : 'toosimple'; $errorMessage = Platform::getInstance()->translate('COM_AKEEBA_CPANEL_ERR_FESECRETWORD_' . $error); throw new \RuntimeException($errorMessage, 403); }