[Laravel5.2 documentation] service-hash
1. Introduction
Laravel's Hash facade provides a secure Bcrypt Hash algorithm for storing user passwords. If you are using the AuthController controller that comes with the Laravel application, this Bcrypt will be automatically used for registration and authentication.
Bcrypt is an excellent choice for hash passwords, because its "working factor" is adjustable, which means that as hardware functions increase, the time required to generate hash will also increase.
2. Basic use
You can call the make method on the Hash facade to Hash the storage password:
Fill (['password' => Hash: make ($ request-> newPassword)])-> save ();}}
In addition, you can use the global auxiliary function bcrypt:
bcrypt('plain-text');
Verify the hash password
The check method allows you to verify whether the given native string is equal to the given hash. However, if you are using the AuthController provided by Laravel (see the user authentication section for details), you do not need to directly use this method, because the built-in authentication controller automatically calls this method:
If (Hash: check ('plain-text', $ hashedPassword) {// password match ...}
Check if the password needs to be re-hashed
The needsRehash method allows you to determine whether the working factor used by the hash calculator has changed after the last password was hashed:
if (Hash::needsRehash($hashed)) { $hashed = Hash::make('plain-text');}