Hashing is the process of transforming a string of characters into a shorter fixed value or a key that represents the original string. Laravel uses theHashfacade which provides a secure way for storing passwords in a hashed manner.
The following screenshot shows how to create a controller namedpasswordControllerwhich is used for storing and updating passwords −
The following lines of code explain the functionality and usage of thepasswordController−
user()->fill([ 'password' => Hash::make($request->newLaravel - 哈希) // Hashing passwords ])->save(); } }
The hashed passwords are stored usingmakemethod. This method allows managing the work factor of thebcrypthashing algorithm, which is popularly used in Laravel.
You should verify the password against hash to check the string which was used for conversion. For this you can use thecheckmethod. This is shown in the code given below −
if (Hash::check('plain-text', $hashedLaravel - 哈希)) { // The passwords match... }
Note that thecheckmethod compares the plain-text with thehashedLaravel - 哈希variable and if the result is true, it returns a true value.
以上是Laravel - 哈希的详细内容。更多信息请关注PHP中文网其他相关文章!