Determine whether the given string contains one of the registered signatures

@param string $string    the string data to check
@param string $signature the hex signature

@throws \InvalidArgumentException

@return bool
166655
public static function hasSignature($string, $signature)
    {
        if (ctype_xdigit($signature) === false) {
            throw new \InvalidArgumentException(sprintf('Invalid HEX signature provided: %s', $signature));
        }
        $signatureChars = str_split($signature, 2);
        $hexChars = array_map(
            function ($val) {
                return strtoupper(bin2hex($val));
            },
            str_split(substr($string, 0, count($signatureChars)))
        );

        return $hexChars === $signatureChars;
    }
1152722
public function contains($className)
    {
        if (!is_string($className)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($className) ? get_class($className) : gettype($className))));
        }

        $this->parseClassAttribute();

        return in_array($className, $this->classes, true);
    }
516921
private function compare(array $signature, array $metadata): bool
    {
        foreach ($signature as $key => $v1) {

            $v2 = $metadata[$key] ?? null;

            if (! is_null($v2) && $v1 !== $v2) return false;

        }

        return true;
    }
430351
public function verifyTokenSignature($signature, $data, PublicKey $publicKey)
    {
        if (!$publicKey instanceof VirgilPublicKey) {
            throw new VirgilCryptoException("instance of VirgilPublicKey expected");
        }

        return $this->virgilCrypto->verifySignature($data, $signature, $publicKey);
    }
454387
public function getAuthorization($signature, $string = true)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a string
            ->test(1, 'string')
            //Argument 2 must be a boolean
            ->test(2, 'bool');
        
        //this is all possible configurations
        $params = array(
            'realm'     => $this->realm,
            'oauth_consumer_key' => $this->consumerKey,
            'oauth_token' => $this->requestToken,
            'oauth_signature_method' => self::HMAC_SHA1,
            'oauth_signature' => $signature,
            'oauth_timestamp' => $this->time,
            'oauth_nonce' => $this->nonce,
            'oauth_version'     => self::OAUTH_VERSION,
            'oauth_verifier' => $this->verifier,
            'oauth_callback' => $this->callback);
        
        //if no realm
        if (is_null($this->realm)) {
            //remove it
            unset($params['realm']);
        }
        
        //if no token
        if (is_null($this->requestToken)) {
            //remove it
            unset($params['oauth_token']);
        }
        
        //if no verifier
        if (is_null($this->verifier)) {
            //remove it
            unset($params['oauth_verifier']);
        }
        
        
        //if no callback
        if (is_null($this->callback)) {
            //remove it
            unset($params['oauth_callback']);
        }
        
        if (!$string) {
            return $params;
        }
        
        return sprintf(self::AUTH_HEADER, $this->buildQuery($params, ',', false));
    }
823040
public function matches(string $string) : bool
    {
        $matches = [];

        return (bool)call_user_func_array(
            $this->_method,
            [
                sprintf("/%s/%s", $this->_expr, $this->_flags),
                $string,
                &$matches,
                $this->_pregMatchFlags ?: null,
            ]
        );
    }
861384
function verify($message, $signature)
    {
        if (empty($this->modulus) || empty($this->exponent)) {
            return false;
        }

        switch ($this->signatureMode) {
            case self::SIGNATURE_PKCS1:
                return $this->_rsassa_pkcs1_v1_5_verify($message, $signature);
            //case self::SIGNATURE_PSS:
            default:
                return $this->_rsassa_pss_verify($message, $signature);
        }
    }
586707
public static function isNotEmpty($string)
    {
        if (!self::isValid($string) &&
            null !== $string
        ) {
            return false;
        }

        return (!self::isEmpty($string));
    }
356097
public function detect($string, $inBlock = false)
    {
        $this->_detectMatch = false;
        if ($this->isOpen) {
            if (self::isMyLine($string)) {
                $this->needsClosing = true;
                return true;
            }

            if (!$this->needsClosing) {
                $this->_currentContent .= $string . "\n";
                return true;
            }

            return false;
        } else if (self::isMyLine($string)) {
            $this->needsClosing = false;
            $this->_programmingLanguage = trim(substr($string, 3));
            return true;
        }
        $this->isOpen = false;
        return false;
    }
115552
private function checkB64HeaderAndCrit(SignatureInterface $signature)
    {
        if (!$signature->hasProtectedHeader('b64')) {
            return;
        }

        Assertion::true($signature->hasProtectedHeader('crit'), 'The protected header parameter "crit" is mandatory when protected header parameter "b64" is set.');
        Assertion::isArray($signature->getProtectedHeader('crit'), 'The protected header parameter "crit" must be an array.');
        Assertion::inArray('b64', $signature->getProtectedHeader('crit'), 'The protected header parameter "crit" must contain "b64" when protected header parameter "b64" is set.');
    }
1236753
function _sign($key, $signatureAlgorithm)
    {
        switch (strtolower(get_class($key))) {
            case 'crypt_rsa':
                switch ($signatureAlgorithm) {
                    case 'md2WithRSAEncryption':
                    case 'md5WithRSAEncryption':
                    case 'sha1WithRSAEncryption':
                    case 'sha224WithRSAEncryption':
                    case 'sha256WithRSAEncryption':
                    case 'sha384WithRSAEncryption':
                    case 'sha512WithRSAEncryption':
                        $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
                        $key->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);

                        $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject));
                        return $this->currentCert;
                }
            default:
                return false;
        }
    }
1007386
private function verify($data, $signature, $publicKey)
    {
        $res = openssl_get_publickey($publicKey);
        $result = (bool) openssl_verify($data, base64_decode($signature), $res);
        openssl_free_key($res);

        return $result;
    }
1101263
public function contains($string): bool
    {
        try {
            Assert::typeOf(['string', __CLASS__], $string);
        } catch (InvalidArgumentException|TypeError $t) {
            return false;
        }

        return mb_strpos($this->data, (string) $string, 0, $this->encoding) !== false;
    }
1499
function _sign($key, $signatureAlgorithm)
    {
        if ($key instanceof RSA) {
            switch ($signatureAlgorithm) {
                case 'md2WithRSAEncryption':
                case 'md5WithRSAEncryption':
                case 'sha1WithRSAEncryption':
                case 'sha224WithRSAEncryption':
                case 'sha256WithRSAEncryption':
                case 'sha384WithRSAEncryption':
                case 'sha512WithRSAEncryption':
                    $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
                    $key->setSignatureMode(RSA::SIGNATURE_PKCS1);

                    $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject));
                    return $this->currentCert;
            }
        }

        return false;
    }
544432
public function isValid(string $key) : bool
    {
        if (!$this->headers->has($this->algorithmHeader)) {
            return false;
        }

        if (!$this->headers->has($this->signatureHeader)) {
            return false;
        }

        $signature = new Signature(new Payload($this->request), $this->getAlgorithm(), $key);

        return $signature->equals($this->getSignature());
    }
29982
protected function isValidToken($text)
    {
        // Make sure $text is string
        if (!is_string($text)) {
            throw new InvalidArgumentException(
                '$text must be string'
            );
        }

        $separators = [
            '(', ')', '<', '>', '@',
            ',', ';', ':', '\\', '"',
            '/', '[', ']', '?', '=',
            '{', '}', 32, 9
        ];

        // If contains separator, return false
        foreach ($separators as $s) {
            if (strpos($text, $s) !== false) {
                return false;
            }
        }

        // If contains control character, return false
        if (ctype_cntrl($text)) {
            return false;
        }

        return true;
    }
644150
public function check_signature(Request $request, Consumer $consumer, Token $token, string $signature): bool
	{
		$built = $this->build_signature($request, $consumer, $token);
		return $built == $signature;
	}