App\Hashing\OsuHasher::make PHP Method

make() public method

Hash the given value.
public make ( string $value, array $options = [] ) : string
$value string
$options array
return string
    public function make($value, array $options = [])
    {
        $cost = array_get($options, 'cost', $this->rounds);
        // When we originally moved to bcrypt (quite a few years ago),
        // we had to migrate everything without waiting for every user to
        // change their passwords, hence the md5 still being there.
        $hash = password_hash(md5($value), PASSWORD_BCRYPT, ['cost' => $cost]);
        // see static::check()
        return str_replace('$2y$', '$2a$', $hash);
    }

Usage Example

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