Question

Is there any way to use Laravel's Auth and Hash, but change the bcrypt cost?

The default is defined here http://laravel.com/api/source-class-Illuminate.Hashing.BcryptHasher.html

Was it helpful?

Solution

Take a look at the make method.

You can pass an options array as the second parameter, where you can define the cost value.

Hash::make('stringtobehashed', array('cost' => 20));

OTHER TIPS

I know this thread is very old, but just for quick reference,

If you're using Laravel 4.0 and up, change cost to rounds. You can look at the code here.

EDIT:

Alternatively and as of Laravel 4.2, you can set the rounds once and for all, in some ServiceProvider's boot method (probably in the AppServiceProvider), using: Hash::setRounds(12);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top