App\Hashing\OsuHasher::check PHP Method

check() public method

Check the given plain value against a hash.
public check ( string $value, string $hashedValue, array $options = [] ) : boolean
$value string
$hashedValue string
$options array
return boolean
    public function check($value, $hashedValue, array $options = [])
    {
        // To clarify here: the 2y implementation of bcrypt is specific to
        // the crypt_blowfish implementation of bcrypt (that PHP uses).
        // the act of naming this bugfix "2y" was a stupid idea as it is not
        // an updated version of the algorithm at all.
        // 2a and 2y are literally identical; crypt_blowfish just had bugs in 2a
        // anyways, this replacement is because the .NET library this interacts with
        // needs 2a since a string replacement on every connection is needless overhead
        // for a realtime processing server and only lowers max connections.
        $hashedValue = str_replace('$2a$', '$2y$', $hashedValue);
        return password_verify(md5($value), $hashedValue);
    }

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]));
 }