Skip to content

Provides password hashing utilities

License

Notifications You must be signed in to change notification settings

symfony/password-hasher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d8bd3d6 · Sep 25, 2024
Sep 25, 2024
Aug 2, 2024
Jan 23, 2024
Jun 20, 2024
May 14, 2024
Jul 6, 2024
Feb 12, 2021
Jul 11, 2022
Jan 24, 2023
Jan 23, 2024
Jul 11, 2022
Dec 8, 2023
May 23, 2023
Jun 2, 2021

Repository files navigation

PasswordHasher Component

The PasswordHasher component provides secure password hashing utilities.

Getting Started

composer require symfony/password-hasher
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory;

// Configure different password hashers via the factory
$factory = new PasswordHasherFactory([
    'common' => ['algorithm' => 'bcrypt'],
    'memory-hard' => ['algorithm' => 'sodium'],
]);

// Retrieve the right password hasher by its name
$passwordHasher = $factory->getPasswordHasher('common');

// Hash a plain password
$hash = $passwordHasher->hash('plain'); // returns a bcrypt hash

// Verify that a given plain password matches the hash
$passwordHasher->verify($hash, 'wrong'); // returns false
$passwordHasher->verify($hash, 'plain'); // returns true (valid)

Resources