@param string $payload
@param string $publicKey
@param string $signature

@return bool
189375
public function isValid($payload, $publicKey, $signature)
    {
        return openssl_verify($payload, $signature, $publicKey, $this->hashAlgorithm) === 1;
    }
1110217
private function sign(array $payload): string
    {
        $jsonConverter = new StandardConverter();
        $payload = array_merge(
            $payload,
            $this->getAdditionalPayload()
        );
        $headers = $this->getSignatureHeader();
        $signatureKey = $this->signatureKeyset->get($this->signatureKeyIndex);
        if ($signatureKey->has('kid')) {
            $headers['kid'] = $signatureKey->get('kid');
        }

        $jws = $this->jwsBuilder
            ->create()
            ->withPayload($jsonConverter->encode($payload))
            ->addSignature($signatureKey, $headers)
            ->build();

        $serializer = new JWSCompactSerializer($jsonConverter);

        return $serializer->serialize($jws, 0);
    }
1310275
public function verify($key, $signature, $input)
    {
        $signedInput = $this->sign($input, $key);

        return $this->timingSafeEquals($signedInput, $signature);
    }
158833
public function withPayload(string $payload, bool $isPayloadDetached = false): self
    {
        if (false === \mb_detect_encoding($payload, 'UTF-8', true)) {
            throw new \InvalidArgumentException('The payload must be encoded in UTF-8');
        }
        $clone = clone $this;
        $clone->payload = $payload;
        $clone->isPayloadDetached = $isPayloadDetached;

        return $clone;
    }
248724
public function verifyWithKey(Object\JWSInterface $jws, Object\JWKInterface $jwk, $detached_payload = null, &$recipient_index = null)
    {
        $jwk_set = new Object\JWKSet();
        $jwk_set->addKey($jwk);

        $this->verifySignatures($jws, $jwk_set, $detached_payload, $recipient_index);
    }
1283000
protected function verify($data, $sign)
    {
        $content = wordwrap($this->config->get('public_key'), 64, "\n", true);
        $res = "-----BEGIN PUBLIC KEY-----\n{$content}\n-----END PUBLIC KEY-----";
        if ($this->options->get('sign_type') === 'RSA2') {
            if (openssl_verify(json_encode($data, 256), base64_decode($sign), $res, OPENSSL_ALGO_SHA256) !== 1) {
                throw new InvalidResponseException('Data signature verification failed.');
            }
        } else {
            if (openssl_verify(json_encode($data, 256), base64_decode($sign), $res, OPENSSL_ALGO_SHA1) !== 1) {
                throw new InvalidResponseException('Data signature verification failed.');
            }
        }
        return $data;
    }
983342
public static function verifyWithPKCS15(RSAKey $key, string $message, string $signature, string $hash): bool
    {
        if (\mb_strlen($signature, '8bit') !== $key->getModulusLength()) {
            throw new \InvalidArgumentException();
        }
        $signature = BigInteger::createFromBinaryString($signature);
        $m2 = RSAKey::exponentiate($key, $signature);
        $em = self::convertIntegerToOctetString($m2, $key->getModulusLength());

        return \hash_equals($em, self::encodeEMSA15($message, $key->getModulusLength(), Hash::$hash()));
    }
1166182
public function checkRevokedToken($token, $payload)
    {
        if(!empty($payload) && Yii::$app->cache)
        {
            return Yii::$app->cache->get($this->getRevokedTokenCacheKey($token)) !== false;
        }
        return false;
    }
8547
public static function verifyUser($payload)
    {
        $userId = $payload->get('user_id');
        $userKey = $payload->get('sub');
        $userInfo = ($userId) ? User::getCachedInfo($userId) : null;

        if (!empty($userInfo) && $userKey === md5($userInfo['email'])) {
            return true;
        } else {
            throw new TokenInvalidException('User verification failed.');
        }
    }
667210
public static function verifyWebhookSignature($signature, $message, $secretKey)
    {
        $data = "";

        if (is_string($message)) {
            $data = $message;
        } else {
            $data = json_encode($message);
        }
        return hash_hmac("sha256", $data, $secretKey) == $signature;
    }
546840
function verify($data, $signature) {
    $status = openssl_verify($data, $signature, $this->publicKey, "sha256");
    if ($status === -1) {
      throw new Exception('Signature verification error: ' . openssl_error_string());
    }
    return $status === 1;
  }
103308
public function verifyWebhookSignature(int $timestamp, string $token, string $signature): bool
    {
        if (empty($timestamp) || empty($token) || empty($signature)) {
            return false;
        }

        $hmac = hash_hmac('sha256', $timestamp.$token, $this->apiKey);

        if (function_exists('hash_equals')) {
            // hash_equals is constant time, but will not be introduced until PHP 5.6
            return hash_equals($hmac, $signature);
        } else {
            return $hmac === $signature;
        }
    }
356947
public static function signRequest(
        AbstractRequestHandler $requestHandler,
        $endpoint,
        $httpMethod,
        Payload $payload = null
    ) {
        $endPointPath = self::generateEndPointPath($endpoint, $requestHandler->getSDKId());

        $messageToSign = "{$httpMethod}&$endPointPath";
        if ($payload instanceof Payload) {
            $messageToSign .= "&{$payload->getBase64Payload()}";
        }

        openssl_sign($messageToSign, $signedMessage, $requestHandler->getPem(), OPENSSL_ALGO_SHA256);

        self::validateSignedMessage($signedMessage);

        $base64SignedMessage = base64_encode($signedMessage);

        return [
            self::SIGNED_MESSAGE_KEY => $base64SignedMessage,
            self::END_POINT_PATH_KEY => $endPointPath
        ];
    }
375301
public function hasSigned(Signature $signature)
    {
        $key = openssl_pkey_get_public($this->x509Cert);

        try {
            $hasSigned = $signature->isSignedByKey($key);
        } catch (\Excetpion $e) {
            openssl_pkey_free($key);
            throw $e;
        }

        openssl_pkey_free($key);

        return $hasSigned;
    }
1282904
public function sign($payload, $key)
    {
        if (!$key instanceof Key) {
            $key = new Key($key);
        }
        $privateKey = $this->keyParser->parsePrivateKey($key->getContent());

        $hash = $this->hash($payload);

        $random = RandomGeneratorFactory::getRandomGenerator();
        $randomK = $random->generate($this->config->getGenerator()->getOrder());

        $signer = new EccSigner($this->adapter);
        $signature = $signer->sign($privateKey, $hash, $randomK);

        return new LcobucciJWTSignature($this->serializer->serialize($signature, $this->config->getSignatureLength()));
    }
1234414
public static function verifySignature($message, $signature, $signatureKey, $algorithm = 'MD5')
    {
        if (isset($signature)) {
            if ($algorithm === 'MD5') {
                $hash = md5($message . $signatureKey);
            } else if (in_array($algorithm, array('SHA', 'SHA1', 'SHA-1'))) {
                $hash = sha1($message . $signatureKey);
            } else {
                $hash = hash('sha256', $message . $signatureKey);
            }

            if (strcmp($signature, $hash) == 0) {
                return true;
            }
        }

        return false;
    }
1100299
public static function validate($payload, $secret, $signature)
    {
        return hash_equals(self::compute($payload, $secret), $signature);
    }