Corcel\Password\PasswordService::check PHP 메소드

check() 공개 메소드

Maintains compatibility between old version and the new cookie authentication protocol using PHPass library. The $hash parameter is the encrypted password and the function compares the plain text password when encrypted similarly against the already encrypted password to see if they match. For integration with other applications, this function can be overwritten to instead use the other package password checking algorithm.
부터: 2.5.0
public check ( string $password, string $hash, string | integer $user_id = '' ) : boolean
$password string Plaintext user's password
$hash string Hash of the user's password to check against.
$user_id string | integer Optional. User ID.
리턴 boolean False, if the $password does not match the hashed password
    public function check($password, $hash, $user_id = '')
    {
        // If the hash is still md5...
        if (strlen($hash) <= 32) {
            return $hash === md5($password);
        }
        // If the stored hash is longer than an MD5, presume the
        // new style phpass portable hash.
        return $this->hasher->CheckPassword($password, $hash);
    }

Usage Example

예제 #1
0
 public function testPasswordService()
 {
     $checker = new PasswordService();
     $this->assertTrue($checker->check('admin', $checker->makeHash('admin')));
     $this->assertTrue($checker->check('admin', '$P$BrYiES.08ardK6pQme0LdlmQ0idrIe/'));
     $this->assertTrue($checker->check('rEn2b2N3TX', $checker->makeHash('rEn2b2N3TX')));
     $this->assertTrue($checker->check('+0q?\'t&SBT\'*2VBk7UE(,uj6UG23Us', $checker->makeHash('+0q?\'t&SBT\'*2VBk7UE(,uj6UG23Us')));
 }
All Usage Examples Of Corcel\Password\PasswordService::check