Verifies the data (string) against the given signature using the extension assigned to the type in the constructor.
@param string $data
@param string $signature
@return bool|int
199083
public function verifySignature($data, $signature)
    {
        switch ($this->cryptParams['library']) {
            case 'openssl':
                return $this->verifyOpenSSL($data, $signature);
            case (self::HMAC_SHA1):
                $expectedSignature = hash_hmac("sha1", $data, $this->key, true);
                return strcmp($signature, $expectedSignature) == 0;
        }
    }
1159215
public function validate($data) {
        // allow paramtype to be a custom regex if it is the form of /pattern/
        if (preg_match('#^/.*/$#', $this->paramtype)) {
            if (preg_match($this->paramtype, $data)) {
                return true;
            } else {
                return get_string('validateerror', 'admin');
            }

        } else if ($this->paramtype === PARAM_RAW) {
            return true;

        } else {
            $cleaned = clean_param($data, $this->paramtype);
            if ("$data" === "$cleaned") { // implicit conversion to string is needed to do exact comparison
                return true;
            } else {
                return get_string('validateerror', 'admin');
            }
        }
    }
719894
public function setByteType($signature)
	{
		if ($signature === self::TIF_SIGNATURE_INTEL)
		{
			$this->typeLong = 'V';
			$this->typeShort = 'v';
			$this->size['type'] = IMAGETYPE_TIFF_II;
		}
		else
		{
			$this->typeLong = 'N';
			$this->typeShort = 'n';
			$this->size['type'] = IMAGETYPE_TIFF_MM;
		}
	}
618735
public function verifyStreamSignature($source, $signature, VirgilPublicKey $signerPublicKey)
    {
        try {
            return $this->cryptoService->verifyStream($source, $signature, $signerPublicKey->getValue());
        } catch (Exception $exception) {
            throw new VirgilCryptoException($exception->getMessage());
        }
    }
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;
    }
990124
public function verifySignature(?string $signature = null): bool
	{
		// check merchantId and accountId from request
		if (
			$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
			|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
		) {
			throw new InvalidSignatureException();
		}

		if ($signature === null) {
			$signature = $this->signature;
		}

		// Compute the signature for specified arguments, and compare it to the specified signature.

		$out = [];
		$out[] = 'merchantId=' . $this->getRequestMerchantId();
		$out[] = 'accountId=' . $this->getRequestAccountId();
		foreach (array_merge(self::$REQUIRED_ARGS, self::$OPTIONAL_ARGS) as $property) {
			if ($this->{$property} !== null) {
				$value = $this->{$property};

				if (in_array($property, self::$FLOAT_ARGS, true)) {
					$value = number_format($value, 2, '.', '');
				} elseif (in_array($property, self::$BOOL_ARGS, true)) {
					$value = $value ? '1' : '0';
				}

				$out[] = sprintf('%s=%s', $property, $value);
			}
		}

		$out[] = 'password=' . $this->getMerchantConfig()->password;

		$sig = $this->hashFunction(implode('&', $out));

		if ($sig === $signature) {
			return true;
		}

		throw new InvalidSignatureException();
	}
389254
public function validate($data, $type) {
        if (strtolower($type) == "create") $rules = $this->repository->getValidationRulesForCreate();

        if (strtolower($type) == "update") $rules = $this->repository->getValidationRulesForUpdate();

        $validator = Validator::make($data,$rules);

        if ($validator->fails()) return $validator->messages();

        return "passed";
    }
1242920
public function verify($token, $data=null)
    {
        $data = static::formatData($data);
        
        $key = trim($token);
        
        // if shared, use same key based data
        if ($this->options['shared']) {
            $key = md5(serialize($data));
            $data['_token_'] = $token;
        }
        
        $sdata = static::getStorage()->get($key);
        
        if (!$sdata || !isset($sdata['_expire_time_'])) {
            return ErrorInfo::error(ErrorInfo::ERR_TOKEN_INVALID, $this->getTitle() . ' 已过期，请刷新重试[0]。');
        } else {
            if (time() > $sdata['_expire_time_'] ) {
                // if auto refresh, reset old token and return new token
                if ($this->options['auto_refresh']) {
                    
                    $this->reset($token, $data);
                    
                    $newtoken = static::get($data);
                    return ErrorInfo::success(['token'=>$newtoken, 'refresh_token'=>$token]);
                }
                
                return ErrorInfo::error(ErrorInfo::ERR_TOKEN_EXPIRED, $this->getTitle() . ' 已过期，请刷新重试[1]。');
            }
            
            if ($data) {
                foreach ($data as $k => $v) {
                    if (!isset($sdata[$k]) || $v != $sdata[$k]) {
                        $msg = sprintf($this->getTitle() . ' 不正确[%s]', $k);
                        return ErrorInfo::error(ErrorInfo::ERR_TOKEN_DATA, $msg);
                        break;
                    }
                }
            }
        }
        
        return ErrorInfo::success($this->options['name'] . ' 正确');
    }
990159
public function mpsDecode($data_encrypted, $signature)
    {
        try {
            $inputParams = [
                'data_encrypted' => $data_encrypted,
                'signature'      => $signature,
            ];
            $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
            $movitelMps = new MovitelMps\MovitelMps($this->options);
            $movitelMps->setMovitelPublicKey($this->movitelPublicKey);
            $movitelMps->setMovitelPrivateKey($this->movitelPrivateKey);
            $movitelMps->setCpPublicKey($this->cpPublicKey);
            $movitelMps->setCpPrivateKey($this->cpPrivateKey);
            $response = $movitelMps->decodeResponseFromMps($data_encrypted, $signature);
            $this->debug->info(__FUNCTION__, 'decode Response From Mps: ' . json_encode($response));
            if (isset($response) && $response !== NULL && count($response) > 0) {
                if ($this->nativeSession === TRUE) {
                    $this->debug->info(__FUNCTION__, 'Movitel Set Session MSISDN Native: ' . json_encode($response['msisdn']));
                    Session::setUserdata(self::SESSION_MSISDN_DEFAULT, $response['msisdn']);
                }
                if ($response['msisdn'] == "" || $response['msisdn'] == "GUEST") {
                    // Không nhận diện được thuê bao
                    $mpsResult = [
                        'status' => 1,
                        'msisdn' => NULL
                    ];
                } else {
                    // Nhận diện được thuê bao
                    $mpsResult = [
                        'status'       => 0,
                        'msisdn'       => $response['msisdn'],
                        'request_ip'   => $response['request_ip'],
                        'request_id'   => $response['request_id'],
                        'response_id'  => $response['response_id'],
                        'price'        => $response['price'],
                        'source'       => $response['source'],
                        'command'      => $response['command'],
                        'content_logs' => $response['content_logs']
                    ];
                    if ($this->nativeSession === TRUE) {
                        $this->debug->info(__FUNCTION__, 'set native Session Mps Result');
                        Session::setUserdata(self::SESSION_MPS_RESULT, json_encode($mpsResult));
                    }
                }
                $this->debug->info(__FUNCTION__, 'MPS Result: ' . json_encode($mpsResult));

                return $mpsResult;
            } else {
                $this->debug->info(__FUNCTION__, 'MPS Not Response or Response is Empty');

                return NULL;
            }
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
66132
private function validate(array $data, $strict, $passwordType)
    {
        if (!isset($data['InvId'], $data['OutSum'], $data['SignatureValue'])) {
            return false;
        }

        $this->set($data);
        $this->setId($data['InvId']);

        $this->valid = strcasecmp($data['SignatureValue'], $this->auth->getSignatureHash(
            '{os}:{ii}:{pp}{:cp}',
            [
                'os' => $data['OutSum'],
                'ii' => $data['InvId'],
                'pp' => $this->auth->{'get' . $passwordType . 'Password'}(),
                'cp' => $this->getCustomParamsString(),
            ]
        )) === 0;

        if ($this->valid && $strict) {
            try {
                $this->fetch();
                $this->valid = $data['OutSum'] == $this->shopSum
                               && Payment::STATE_COMPLETED === $this->stateCode;
            } catch (InvoiceNotFoundException $e) {
                $this->valid = false;
            }
        }

        return $this->valid;
    }
238295
public function mpsDecode($data_encrypted, $signature)
    {
        try {
            $inputParams = [
                'data_encrypted' => $data_encrypted,
                'signature'      => $signature,
            ];
            $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
            $viettelMps = new ViettelMps\ViettelMps($this->options);
            $viettelMps->setViettelPublicKey($this->viettelPublicKey);
            $viettelMps->setViettelPrivateKey($this->viettelPrivateKey);
            $viettelMps->setCpPublicKey($this->cpPublicKey);
            $viettelMps->setCpPrivateKey($this->cpPrivateKey);
            $response = $viettelMps->decodeResponseFromMps($data_encrypted, $signature);
            $this->debug->info(__FUNCTION__, 'decode Response From Mps: ' . json_encode($response));
            if (isset($response) && $response !== NULL && count($response) > 0) {
                if ($this->nativeSession === TRUE) {
                    $this->debug->info(__FUNCTION__, 'Viettel Set Session MSISDN Native: ' . json_encode($response['msisdn']));
                    Session::setUserdata(self::SESSION_MSISDN_DEFAULT, $response['msisdn']);
                }
                if ($response['msisdn'] == "" || $response['msisdn'] == "GUEST") {
                    // Không nhận diện được thuê bao
                    $mpsResult = [
                        'status' => 1,
                        'msisdn' => NULL
                    ];
                } else {
                    // Nhận diện được thuê bao
                    $mpsResult = [
                        'status'       => 0,
                        'msisdn'       => $response['msisdn'],
                        'request_ip'   => $response['request_ip'],
                        'request_id'   => $response['request_id'],
                        'response_id'  => $response['response_id'],
                        'price'        => $response['price'],
                        'source'       => $response['source'],
                        'command'      => $response['command'],
                        'content_logs' => $response['content_logs']
                    ];
                    if ($this->nativeSession === TRUE) {
                        $this->debug->info(__FUNCTION__, 'set native Session Mps Result');
                        Session::setUserdata(self::SESSION_MPS_RESULT, json_encode($mpsResult));
                    }
                }
                $this->debug->info(__FUNCTION__, 'MPS Result: ' . json_encode($mpsResult));

                return $mpsResult;
            } else {
                $this->debug->info(__FUNCTION__, 'MPS Not Response or Response is Empty');

                return NULL;
            }
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
1076357
function verify($text, $signature)
    {
        try {
            $verified = $this->gpg->verify($text, $signature);
            return $this->parse_signature($verified[0]);
        }
        catch (Exception $e) {
            return $this->get_error_from_exception($e);
        }
    }
794786
public static function validateSignature($signature, $payload)
    {
        $parts = explode(',', $signature);
        $parameters = [];
        $t = 0;
        // Find the timestamp
        foreach ($parts as $part) {
            parse_str($part, $parsed);
            if (key($parsed) === 't') {
                $t = $parsed['t'];
                break;
            }
        }

        if ($t === 0) {
            return false;
        }

        $wanted = hash_hmac('sha256', $t . '.' . $payload, self::$secret);

        // Find v1 hashes
        foreach ($parts as $part) {
            parse_str($part, $parsed);
            if (key($parsed) === 'v1') {
                if ($wanted === $parsed['v1']) {
                    return true;
                }
            }
        }

        return false;
    }
459897
protected function validWBMP($data)
	{
		return ord($data[0]) === 0 && ord($data[1]) === 0 && $data !== substr(TypeJp2::JPEG_2000_SIGNATURE, 0, self::LONG_SIZE);
	}
88116
public function signData($data)
    {
        switch ($this->cryptParams['library']) {
            case 'openssl':
                return $this->signOpenSSL($data);
            case (self::HMAC_SHA1):
                return hash_hmac("sha1", $data, $this->key, true);
        }
    }
192272
public static boolean verify(byte[] data, byte[] signature, byte[] pub) {
        return verify(data, ECDSASignature.decodeFromDER(signature), pub);
    }
1100299
public static function validate($payload, $secret, $signature)
    {
        return hash_equals(self::compute($payload, $secret), $signature);
    }