Files
FreshRSS/app/Utils/passwordUtil.php
T
InverleandAlexandre Alapetite 6af8ebcbff Fix current password requirement during password changes (#9550)
* Fix current password requirement during password changes

Regression from #9358 (follow-up, PR not present in a stable/versioned release)

Fix [GHSA-5vxm-62pg-frff](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-5vxm-62pg-frff)

* Remove stale client side bcrypt comment from passwordUtil

* docs: PHP 8.1 is no longer supported

* Minor typographic preference

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-10 01:13:52 +01:00

24 lines
554 B
PHP

<?php
declare(strict_types=1);
class FreshRSS_password_Util {
public const BCRYPT_COST = 9;
/**
* Return a hash of a plain password, using BCRYPT
*/
public static function hash(#[\SensitiveParameter] string $passwordPlain): string {
$passwordHash = password_hash(
$passwordPlain,
PASSWORD_BCRYPT,
['cost' => self::BCRYPT_COST]
);
return $passwordHash;
}
public static function cryptAvailable(): bool {
$hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG';
return $hash === @crypt('password', $hash);
}
}