Check that a signature (or set of parameters) is valid.

@param array| string $signature

@throws \InvalidArgumentException

@return bool
544608
public function check($signature)
    {
        if (is_array($signature) and isset($signature['sig'])) {
            $signature = $signature['sig'];
        }

        if (!is_string($signature)) {
            throw new \InvalidArgumentException('signature must be string, or present in array or parameters');
        }

        return $signature == $this->signed['sig'];
    }
35849
protected function _signParameters(array $parameters, $key) {
        $algorithm = $this->options['SignatureMethod'];
        $stringToSign = null;
        if (2 === $this->options['SignatureVersion']) {
            $stringToSign = $this->_calculateStringToSignV2($parameters);
//            var_dump($stringToSign);
        } else {
            throw new Exception("Invalid Signature Version specified");
        }
        return $this->_sign($stringToSign, $key, $algorithm);
    }
183278
public function isSignedMessageValid($address, $signature, $message)
    {
        $args = [
            (string)$address,
            (string)$signature,
            (string)$message
        ];
        return $this->rpc->query("verifyMessage", $args);
    }
628697
public function verifyCallbackRequest(array $params)
    {
        return $this->signatureCallback
            ->setOrderId(array_get($params, 'Order_ID'))
            ->setStatus(array_get($params, 'Status'))
            ->setFields(array_except($params, ['Order_ID', 'Status', 'Signature']))
            ->setPassword($this->getPassword())
            ->verify(array_get($params, 'Signature'));
    }
686543
private function verifySignature($body, $signature)
    {
        $expectedSignature = base64_encode(hash_hmac('sha1', $body, $this->secretKey, true));

        if ($signature !== $expectedSignature) {
            throw new InvalidSignatureException('The request signature was invalid');
        }
    }
1105028
public function validateArguments()
    {
        parent::validateArguments();

        if (empty($this->arguments['signature'])
            && (empty($this->arguments['extension']) || empty($this->arguments['main']) || empty($this->arguments['sub'])
            )
        ) {
            throw new \InvalidArgumentException('ifHasAccessToModule view helper requires either "signature" or all three other arguments: "extension", "main" and "sub". Please set arguments properly.', 1496314352);
        }
    }
697895
private function validatePath($path)
    {
        if (is_readable($path) && is_writable($path)) {
            return true;
        }

        throw new InvalidArgumentException(sprintf('Invalid path "%s".', $path));

    }
715973
public function addSignature($signature)
    {
        if (!$this->getSignatures()) {
            return $this->setSignatures(array($signature));
        } else {
            return $this->setSignatures(
                array_merge($this->getSignatures(), array($signature))
            );
        }
    }
682523
public function check(array $auth, array $signature, $prefix)
    {
        if (! isset($auth[$prefix . 'timestamp'])) {
            throw new SignatureTimestampException('The timestamp has not been set');
        }

        if (abs($auth[$prefix . 'timestamp'] - time()) >= $this->grace) {
            throw new SignatureTimestampException('The timestamp is invalid');
        }

        return true;
    }
555882
public function getSignatureValue($signature, array $params)
    {
        foreach ($params as $ph => $param) {
            $signature = str_replace(
                ['{:' . $ph . '}', '{' . $ph . '}'],
                [$param ? ':' . $param : '', $param],
                $signature
            );
        }
        return $signature;
    }
182205
public function check(array $auth, array $signature, $prefix)
    {
        if (! isset($auth[$prefix . 'signature'])) {
            throw new SignatureSignatureException('The signature has not been set');
        }

        if ($auth[$prefix . 'signature'] !== $signature[$prefix . 'signature']) {
            throw new SignatureSignatureException('The signature is not valid');
        }

        return true;
    }
583086
public function verifyToken(Token $token)
    {
        $alg = $token->getHeader('alg');

        if (empty($this->supportedAlgs[$alg])) {
            throw new InvalidParamException('Algorithm not supported');
        }

        $signer = Yii::createObject($this->supportedAlgs[$alg]);
        return $token->verify($signer, $this->key);
    }
771226
public function parse($signature)
    {
        $this->setName($signature);

        $argumentsOptions = $this->extractArgumentsOptions($signature);

        foreach ($argumentsOptions as $value) {
            if (substr($value, 0, 2) !== '--') {
                $input = new Argument($value);
            } else {
                $input = new Option(trim($value, '--'));
            }

            $this->command->addInput($input->parse());
        }
    }
473969
public function validateSign($secret)
	{

		$inputData = $this->input->all();
		Secure::sign($inputData, $this->sid(), $secret);
		if ($inputData['sign'] !== $this->input->sign) {
			throw new ProcessorException(ProcessorException::INVALID_SIGN);
		}

	}
930883
public function hasResponder($type)
    {
        if (!is_string($type) || empty($type)) {
            throw new \InvalidArgumentException('The responder type is invalid');
        }

        return isset($this->responders[$type]);
    }
848043
public function verifyCallback($body, $signature)
    {
        $signature_buffer = base64_decode( $signature );
        return (1 == openssl_verify($body, $signature_buffer, self::getCallbackPublicKey(), OPENSSL_ALGO_SHA256));
    }
250464
protected function createSwiftSigner($signature)
    {
        if (!isset($signature['type'])) {
            throw new InvalidConfigException('Signature configuration should contain "type" key');
        }
        switch (strtolower($signature['type'])) {
            case 'dkim' :
                $domain = ArrayHelper::getValue($signature, 'domain', null);
                $selector = ArrayHelper::getValue($signature, 'selector', null);
                if (isset($signature['key'])) {
                    $privateKey = $signature['key'];
                } elseif (isset($signature['file'])) {
                    $privateKey = file_get_contents(Yii::getAlias($signature['file']));
                } else {
                    throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
                }
                return new \Swift_Signers_DKIMSigner($privateKey, $domain, $selector);
            case 'opendkim' :
                $domain = ArrayHelper::getValue($signature, 'domain', null);
                $selector = ArrayHelper::getValue($signature, 'selector', null);
                if (isset($signature['key'])) {
                    $privateKey = $signature['key'];
                } elseif (isset($signature['file'])) {
                    $privateKey = file_get_contents(Yii::getAlias($signature['file']));
                } else {
                    throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
                }
                return new \Swift_Signers_OpenDKIMSigner($privateKey, $domain, $selector);
            default:
                throw new InvalidConfigException("Unrecognized signature type '{$signature['type']}'");
        }
    }