Hashing
The Atom Hash facade, hash_make and hash_check provides secure Bcrypt and Argon2 hashing for storing user passwords.
Bcrypt is a great choice for hashing passwords because its "work factor" is adjustable, which means that the time it takes to generate a hash can be increased as hardware power increases.
Basic Usage
You may hash a password by calling the make method on the Hash facade or by using the hash_make helper:
$user = App\Models\User::find(1);
$user->password = Hash::make('my_password');
$user->password = hash_make('using helper');Verifying A Password Against A Hash
The check or hash_check methods allows you to verify that a given plain-text string corresponds to a given hash:
if(Hash::check('plain-text', $hashedPassword)) {
// The passwords match...
}
if(hash_check('plain-text', $hashedPassword)) {
// The passwords match...
}Mis à jour
Ce contenu vous a-t-il été utile ?