bcosca/fatfree — pull request #399 by 123Haynes (2013-08-23 21:10:10+00:00)
Title: Suggestion: A new function for the bcrypt plugin.

Hi,

i added a new function to the bcrypt plugin.
It checks if a password needs to be rehashed.
This becomes relevant when you want to increase the costs to make bcrypt even harder to crack.

The new function allows you to do something like that:
```php
// define the new cost
$cost=15;
if ($bcrypt->verify($pw,$hash)==true)
{
if ($bcrypt->password_needs_rehash($hash, $cost))
{
$hash=$bcrypt->hash($pw,null,$cost);
// Save the new hash in the db
}
}
```
if you add this code to the login, the passwords will be rehashed automatically if needed.
You only have to change the $cost variable and you're done :)

Since there are now 2 places which define the default cost i added a constant for it.

I hope this function helps someone :)

kind regards,
Haynes