hash_equals() public static méthode

Safer way to evaluate if hashes equal
public static hash_equals ( string $hash1, string $hash2 ) : boolean
$hash1 string Hash #1
$hash2 string Hash #1
Résultat boolean Pass/fail on hash equality
Exemple #1
0
 /**
  * Verify the token if it exists
  *     Removes the old token and sets up a new one if valid
  *
  * @param \Psecio\Gatekeeper\AuthTokenModel $token Token model instance
  * @return boolean Pass/fail result of the validation
  */
 public function verify(\Psecio\Gatekeeper\AuthTokenModel $token = null)
 {
     if (!isset($this->data[$this->tokenName])) {
         return false;
     }
     if ($token === null) {
         $tokenParts = explode(':', $this->data[$this->tokenName]);
         $token = $this->getById($tokenParts[0]);
     }
     if ($token === false) {
         return false;
     }
     $user = $token->user;
     $userToken = $token->token;
     // Remove the token (a new one will be made later)
     $this->datasource->delete($token);
     if (\Psecio\Gatekeeper\Gatekeeper::hash_equals($this->data[$this->tokenName], $token->id . ':' . hash('sha256', $userToken)) === false) {
         return false;
     }
     $this->setup($user);
     return $user;
 }