2 declare(strict_types = 1);
37 'isValidSalt' =>
'Using Md5PasswordHash::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.0.',
38 'base64Encode' =>
'Using Md5PasswordHash::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.0.',
44 protected const PREFIX =
'$1$';
52 const ITOA64 =
'./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
62 public function checkPassword(
string $plainPW,
string $saltedHashPW):
bool
66 $isCorrect = \password_verify($plainPW, $saltedHashPW);
78 return (
bool)CRYPT_MD5;
91 trigger_error(static::class .
': using a custom salt is deprecated.', E_USER_DEPRECATED);
94 if (!empty($password)) {
126 $isValid = !strncmp(self::PREFIX, $saltedPW, strlen(self::PREFIX));
146 $randomBytes = GeneralUtility::makeInstance(Random::class)->generateRandomBytes(6);
158 $saltWithSettings = $salt;
161 if (strlen($salt) == $reqLenBase64) {
162 $saltWithSettings = self::PREFIX . $salt .
'$';
164 return $saltWithSettings;
174 return './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
185 $isValid = ($skip =
false);
187 if (strlen($salt) >= $reqLenBase64) {
189 if (!strncmp(
'$', $salt, 1)) {
190 if (!strncmp(self::PREFIX, $salt, strlen(self::PREFIX))) {
192 $salt = substr($salt, strlen(self::PREFIX));
198 if (!$skip && strlen($salt) >= $reqLenBase64) {
199 if (preg_match(
'/^[' . preg_quote($this->
getItoa64(),
'/') .
']{' . $reqLenBase64 .
',' . $reqLenBase64 .
'}$/', substr($salt, 0, $reqLenBase64))) {
214 protected function base64Encode(
string $input,
int $count):
string
220 $value = ord($input[$i++]);
223 $value |= ord($input[$i]) << 8;
225 $output .= $itoa64[$value >> 6 & 63];
226 if ($i++ >= $count) {
230 $value |= ord($input[$i]) << 16;
232 $output .= $itoa64[$value >> 12 & 63];
233 if ($i++ >= $count) {
236 $output .= $itoa64[$value >> 18 & 63];
237 }
while ($i < $count);
251 return (
int)ceil($byteLength * 8 / 6);
262 trigger_error(
'This method will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
274 trigger_error(
'This method will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);