Cartalyst\Sentinel\Hashing\BcryptHasher::hash PHP Method

hash() public method

{@inheritDoc}
public hash ( $value )
    public function hash($value)
    {
        $salt = $this->createSalt();
        // Format the strength
        $strength = str_pad($this->strength, 2, '0', STR_PAD_LEFT);
        // Create prefix - "$2y$"" fixes blowfish weakness
        $prefix = PHP_VERSION_ID < 50307 ? '$2a$' : '$2y$';
        return crypt($value, $prefix . $strength . '$' . $salt . '$');
    }

Usage Example

示例#1
0
 public function testSymbolsValue()
 {
     $hasher = new BcryptHasher();
     $hashedValue = $hasher->hash('!"#$%^&*()-_,./:;<=>?@[]{}`~|');
     $this->assertTrue($hashedValue !== '!"#$%^&*()-_,./:;<=>?@[]{}`~|');
     $this->assertTrue($hasher->check('!"#$%^&*()-_,./:;<=>?@[]{}`~|', $hashedValue));
 }
BcryptHasher