Files
FreshRSS/app/Utils/passwordUtil.php
Alexandre Alapetite d0b9611319 Update bcrypt.js from 2.4.4 to 3.0.2 (#7449)
https://github.com/dcodeIO/bcrypt.js/releases/tag/v3.0.0
Can be updated to the latest version with:
`curl -L https://unpkg.com/bcryptjs/umd/index.js > p/scripts/vendor/bcrypt.js`
2025-03-25 10:19:51 +01:00

32 lines
731 B
PHP

<?php
declare(strict_types=1);
class FreshRSS_password_Util {
// Will also have to be computed client side on mobile devices,
// so do not use a too high cost
public const BCRYPT_COST = 9;
/**
* Return a hash of a plain password, using BCRYPT
*/
public static function hash(string $passwordPlain): string {
$passwordHash = password_hash(
$passwordPlain,
PASSWORD_BCRYPT,
['cost' => self::BCRYPT_COST]
);
return $passwordHash;
}
/**
* Verify the given password is valid.
*
* A valid password is a string of at least 7 characters.
*
* @return bool True if the password is valid, false otherwise
*/
public static function check(string $password): bool {
return strlen($password) >= 7;
}
}