Hashing password in Laravel

In Laravel, you can create a hashed password using Bcrypt. The syntax is:

$password = Hash::make('yourpassword');

This creates a hashed password. In the controller or model, you can use it. If a user submits a password through a form using the POST method you can hash the password using the below-given code.

$password = Input::get('passwordformfield'); // password is form field

$hashed = Hash::make($password);

Here the variable $hashed will contain the hashed password. The data you get from the form will be validated and then will be hashed and stored in the database.

For Laravel 5.x versions use:

$password = bcrypt('Name1');

Another way is to use artisan tinker from the command prompt.

    Open the command prompt and go to your projects root directory. Navigate to directory name by typing

cd <directory name>
. Then type:
php artisan tinker
Then 
echo Hash::make(‘somestring’);
This will display the hashed password on the console. Now you can copy it and do what you want.