是否有任何方式使用Laravel的Auth和Hash,但是更改bcrypt成本?使用Laravel Auth/Hash更改bcrypt成本
默認這裏http://laravel.com/api/source-class-Illuminate.Hashing.BcryptHasher.html
是否有任何方式使用Laravel的Auth和Hash,但是更改bcrypt成本?使用Laravel Auth/Hash更改bcrypt成本
默認這裏http://laravel.com/api/source-class-Illuminate.Hashing.BcryptHasher.html
定義看一看的make
方法。
您可以傳遞一個選項數組作爲第二個參數,您可以在其中定義成本值。
Hash::make('stringtobehashed', array('cost' => 20));
我知道這個線程是很老,但只是爲快速參考,
如果您使用Laravel 4.0及以上,改變cost
到rounds
。你可以看看代碼here。
編輯:
或者和Laravel 4.2,你可以設置rounds
一勞永逸,在一些的ServiceProvider的boot
方法(可能在AppServiceProvider
),使用: Hash::setRounds(12);
哦,好吧,我可能儘管如此。 'Auth'不需要知道成本,因爲它是用散列和鹽保存的。 – Znarkus