passwordUtil.php 554 B

1234567891011121314151617181920212223
  1. <?php
  2. declare(strict_types=1);
  3. class FreshRSS_password_Util {
  4. public const BCRYPT_COST = 9;
  5. /**
  6. * Return a hash of a plain password, using BCRYPT
  7. */
  8. public static function hash(#[\SensitiveParameter] string $passwordPlain): string {
  9. $passwordHash = password_hash(
  10. $passwordPlain,
  11. PASSWORD_BCRYPT,
  12. ['cost' => self::BCRYPT_COST]
  13. );
  14. return $passwordHash;
  15. }
  16. public static function cryptAvailable(): bool {
  17. $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG';
  18. return $hash === @crypt('password', $hash);
  19. }
  20. }