cartalyst/sentry — pull request #309 by timemachine3030 (2013-11-02 20:16:02+00:00)
Title: Allow fallback algorithms that get upgraded for better security.

Implements password rehashing according to https://wiki.php.net/rfc/password_hash. Also allows users with legacy systems to define their own hashing functions to verify passwords. Once an outdated password hash is verified the password is rehashed and saved back to the user table.

Example fallback usage:

```php
// Fallback for sha1()
Cartalyst\Sentry\Hashing\NativeHasher::addFallback('sha1', function ($string, $hashedString) {
return (sha1($string) == $hashedString);
});
// Poorly designed static salt:
Cartalyst\Sentry\Hashing\NativeHasher::addFallback('crypt', function ($string, $hashedString, $salt) {
return (crypt($string, $salt) == $hashedString);
}, '12345');
// plain text?
Cartalyst\Sentry\Hashing\NativeHasher::addFallback('pt', function ($string, $hashedString) {
return ($string === $hashedString);
});
```