How to use the bcrypt function of the Laravel?

Asked

Viewed 1,171 times

0

I have a file .php in the public folder of Laravel and for larger reasons I cannot create a controller of it. However, I need to use the function bcrypt to generate the password an encrypted password, but I can’t use this function in a file .php pure in the paste public.

How can I use this function?

  • 1

    It is a mistake to use code in public folder because you need to do so.???

  • PHP natively has the password_hash which port Bcrypt (and Argon2i in PHP 7.2, still in Beta).

1 answer

2

To ensure that it is exactly the same as the bcrypt generated by the Laravel, make a controler to call an ajax, a kind of webservice, this controler you will have the function to return

public function getBcrypt($secret) {

   return bcrypt('secret');

}

in your php file you can call this url via Curl or ajax, will generate the encrypted code perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.