PhpDev.App
symfony/password-hasher

symfony/password-hasher

Stars: 620

Forks: 4

Pull Requests: 1

Issues: 0

Watchers: 5

Last Updated: 2023-08-30 06:26:36

Provides password hashing utilities

License: MIT License

Languages: PHP

https://symfony.com/password-hasher

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

OPEN ISSUES

See all