Bcrypt does not work in Lumen 5.4: calling the undefined function bcrypt ()

I created a new Lumen 5.4 project and tried to sow some data. In the seeder, I used bcrypt to hash the password. But when I run php artisan db:seed , I get this error:

 Call to undefined function bcrypt() 

Why can't I use bcrypt in Lumen? I used to use it in Laravel.

+14
source share
5 answers

You can try:

 app('hash')->make('yourpassword'); 
+37
source

another solution would use Facades \ Hash

 use Illuminate\Support\Facades\Hash; 

code

 'password' => Hash::make('your_password') 
+10
source

Try to do it like this

 'password' => password_hash('123456', PASSWORD_BCRYPT) 
+4
source

try, I can do it fine in my project

  function bcrypt($value, $options = []) { return app('hash')->make($value, $options); } 
0
source

As you already mentioned, bcrypt() does not exist in Lumen. As another workaround, since you mentioned sowing in Lumen, you can just use this in \ Faker \ Generator for the password: $faker->password

-2
source

Source: https://habr.com/ru/post/1265163/


All Articles