App\Hashing\OsuHasher::needsRehash PHP Method

needsRehash() public method

Check if the given hash has been hashed using the given options.
public needsRehash ( string $hashedValue, array $options = [] ) : boolean
$hashedValue string
$options array
return boolean
    public function needsRehash($hashedValue, array $options = [])
    {
        $cost = array_get($options, 'cost', $this->rounds);
        $hashedValue = str_replace('$2a$', '$2y$', $hashedValue);
        return password_needs_rehash($hashedValue, PASSWORD_BCRYPT, ['cost' => $cost]);
    }

Usage Example

Beispiel #1
0
 public function testBasicHashing()
 {
     $hasher = new OsuHasher();
     $value = $hasher->make('password');
     $this->assertNotSame('password', $value);
     $this->assertNotSame(md5('password'), $value);
     $this->assertTrue($hasher->check('password', $value));
     $this->assertFalse($hasher->needsRehash($value));
     $this->assertTrue($hasher->needsRehash($value, ['cost' => 4]));
 }