FestinHegre/vendor/symfony/password-hasher
2024-09-26 17:26:04 +02:00
..
Command Vendor 2024-09-26 17:26:04 +02:00
Exception Vendor 2024-09-26 17:26:04 +02:00
Hasher Vendor 2024-09-26 17:26:04 +02:00
CHANGELOG.md Vendor 2024-09-26 17:26:04 +02:00
composer.json Vendor 2024-09-26 17:26:04 +02:00
LegacyPasswordHasherInterface.php Vendor 2024-09-26 17:26:04 +02:00
LICENSE Vendor 2024-09-26 17:26:04 +02:00
PasswordHasherInterface.php Vendor 2024-09-26 17:26:04 +02:00
README.md Vendor 2024-09-26 17:26:04 +02:00

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