Verify the signature of some data.

@param string $data_to_verify
@param string $base64_signature

@return bool
338662
public function verify($data_to_verify, $base64_signature)
    {
        $calculated_signature = base64_encode(hash_hmac('sha256', $data_to_verify, $this->getSharedKey(), true));
        $verify               = hash_equals($calculated_signature, $base64_signature);

        return $verify;
    }
757163
def verify_signature(message, signature, address):
    
    if (len(signature) != SIGNATURE_LENGTH):
        return False

    try:
        binsig = base64.b64decode(signature)
    except:
        return False

    r = intbytes.from_bytes(binsig[1:33])

    s = intbytes.from_bytes(binsig[33:65])

    val = intbytes.from_bytes(bitcoin_sig_hash(message.encode()))

    pubpairs = possible_public_pairs_for_signature(
        generator_secp256k1,
        val,
        (r, s))

    addr_hash160 = bitcoin_address_to_hash160_sec(address)

    for pair in pubpairs:
        if (public_pair_to_hash160_sec(pair, True) == addr_hash160):
            return True
        if (public_pair_to_hash160_sec(pair, False) == addr_hash160):
            return True

    return False
1150544
public function verify(): bool
    {
        $factory = new PublicKeyFactory;
        $publicKey = $factory->fromHex($this->senderPublicKey);

        return $publicKey->verify(
            Hash::sha256($this->toBytes()),
            SignatureFactory::fromHex($this->signature)
        );
    }
380200
public function verify(string $data, string $signature, int $algorithm = OPENSSL_ALGO_SHA256): bool
    {
        $pubKey = openssl_get_publickey($this->getPubkey());
        if (false === $pubKey) {
            throw new \RuntimeException('Cannot open public key from certificate');
        }
        try {
            $verify = openssl_verify($data, $signature, $pubKey, $algorithm);
            if (-1 === $verify) {
                throw new \RuntimeException('OpenSSL Error: ' . openssl_error_string());
            }
        } finally {
            openssl_free_key($pubKey);
        }
        return (1 === $verify);
    }
1237931
public function verifySign($data = '', $sign = '')
    {
        if (!is_string($sign) || !is_string($sign)) {
            return false;
        }
        return (bool)openssl_verify(
                      $data,
                      base64_decode($sign),
                      self::getPublicKey(),
                      OPENSSL_ALGO_SHA256
                    );
    }
667807
public static function verifyRsa(string $data, string $signature, string $publicKey, string $format = null): bool
    {
        $signature = self::toRaw($signature, $format);
        $key = \openssl_pkey_get_public($publicKey);

        $return = \openssl_verify($data, $signature, $key, OPENSSL_ALGO_SHA256);
        if ($return === -1) {
            throw new CryptoException('RSA signature check error: ' . openssl_error_string());
        }

        return $return === 1;
    }
397927
public boolean isHashEqualsWithBase64(String expectedSignatureBase64, BuilderMode builderMode) {
        try {
            final byte[] signature = build(builderMode);
            return MessageDigest.isEqual(signature, DatatypeConverter.parseBase64Binary(expectedSignatureBase64));
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            return false;
        }
    }
811411
@Override
    public boolean checkSign(byte[] content, byte[] data) {
        try (PooledObject<SignatureHolder> holder = CACHE.get(id).get()) {
            Signature signature = holder.get().getVerify();
            signature.update(content);
            return signature.verify(BASE_64.decrypt(data));
        } catch (Exception e) {
            throw new SecureException("加密失败", e);
        }
    }
1264466
function verify (transaction) {
	var remove = 64;

	if (transaction.signSignature) {
		remove = 128;
	}

	var bytes = getBytes(transaction);
	var data2 = Buffer.alloc(bytes.length - remove);

	for (var i = 0; i < data2.length; i++) {
		data2[i] = bytes[i];
	}

	var hash = crypto.createHash('sha256').update(data2.toString('hex'), 'hex').digest();

	var signatureBuffer = Buffer.from(transaction.signature, 'hex');
	var senderPublicKeyBuffer = Buffer.from(transaction.senderPublicKey, 'hex');
	var res = naclInstance.crypto_sign_verify_detached(signatureBuffer, hash, senderPublicKeyBuffer);

	return res;
}
730502
public function verify($token, $data=null)
    {
        $form_name = $this->getDefaultFormName();
        $token || $token = isset($_POST[$form_name]) ? $_POST[$form_name] : (isset($_GET[$form_name]) ? $_GET[$form_name] : null);
        
        if (!$token) {
            return ErrorInfo::error('需要 form_token 参数');
        }
        
        return parent::verify($token, $data);
    }
960363
public boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature) {
    if (publicKey == null || publicKey.length != 32) {
      throw new IllegalArgumentException("Invalid public key!");
    }

    if (message == null || signature == null || signature.length != 64) {
      return false;
    }

    return provider.verifySignature(publicKey, message, 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;
  }
1038819
public function getEncoded()
    {
        $data = serialize($this->data);
        if (function_exists('gzdeflate'))
        {
            $data = gzdeflate($data);
        }
        $data = base64_encode($data);
        $data .= $this->signature($data);
        return $data;
    }
518451
public function isBase64()
    {
        if (!is_string($this->data)) {
            return false;
        }

        return base64_encode(base64_decode($this->data)) === $this->data;
    }
1142837
public function decodeResponseFromMps($data_encrypted, $signature)
    {
        try {
            $inputParams = [
                'data_encrypted' => $data_encrypted,
                'signature'      => $signature,
            ];
            $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
            $data = str_replace(' ', '+', $data_encrypted);
            $this->debug->debug(__FUNCTION__, 'Data to Encrypt: ' . json_encode($data));
            $verify = openssl_verify($data, base64_decode($signature), self::getViettelPublicKey(), OPENSSL_ALGO_SHA1);
            $this->debug->debug(__FUNCTION__, 'OpenSSL Verify: ' . json_encode($verify));
            //echo('verify: '.$verify. "\n");
            openssl_private_decrypt(base64_decode($data), $data, self::getCpPrivateKey());
            //echo 'value Decrypt with private key: ' .$data. "\n";
            $arr = [];
            parse_str($data, $arr);
            //B7. Giai ma du lieu bang AES
            $value_decrypt = self::decrypt(str_replace(' ', '+', $arr['VALUE']), $arr['KEY']);
            $this->debug->debug(__FUNCTION__, 'Value to Decrypt: ' . json_encode($value_decrypt));
            $array_response = [];
            parse_str($value_decrypt, $array_response);
            $this->debug->debug(__FUNCTION__, 'Response Array: ' . json_encode($array_response));
            //var_dump($array_response); die;
            //$array_response = explode("&", $value_decrypt);
            $IP          = new IP($this->options);
            $phoneNumber = new Phone_number();
            $phoneNumber->setDebugStatus($this->options['debugStatus']);
            $phoneNumber->setLoggerPath($this->options['debugLoggerPath']);
            $phoneNumber->__construct();
            $IP->setHaProxy(TRUE);
            $this->debug->debug(__FUNCTION__, 'IP Object: ' . json_encode($IP));
            $this->debug->debug(__FUNCTION__, 'PhoneNumber Object: ' . json_encode($phoneNumber));
            if (isset($array_response) && count($array_response) > 0) {
                $resultMsisdn = trim($array_response["MOBILE"]);
                $this->debug->info(__FUNCTION__, 'Result MSISDN: ' . json_encode($resultMsisdn));
                if ($resultMsisdn == NULL || $resultMsisdn == "null") {
                    $msisdn = "GUEST";
                } elseif (strpos($resultMsisdn, self::HIDDEN_STRING) || strpos($resultMsisdn, self::HIDDEN_STRING_2)) {
                    $msisdn = trim($resultMsisdn);
                } else {
                    $msisdn = $phoneNumber->format($resultMsisdn);
                }
                $price        = $array_response["PRICE"];
                $source       = $array_response["SOURCE"];
                $command      = $array_response["CMD"];
                $response_id  = $array_response["RES"];
                $request_id   = $array_response["REQ"];
                $content_logs = "";
            } else {
                $msisdn       = "";
                $price        = "";
                $source       = "";
                $command      = "";
                $response_id  = "";
                $request_id   = "";
                $content_logs = "";
            }
            $outResult = [
                'msisdn'       => $msisdn,
                'request_ip'   => $IP->getIpAddress(),
                'request_id'   => $request_id,
                'response_id'  => $response_id,
                'price'        => $price,
                'source'       => $source,
                'command'      => $command,
                'content_logs' => $content_logs,
            ];
            $this->debug->info(__FUNCTION__, 'Final Result: ' . json_encode($outResult));

            return $outResult;
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);
            $outResult = [
                'msisdn'       => NULL,
                'request_ip'   => NULL,
                'request_id'   => NULL,
                'response_id'  => NULL,
                'price'        => NULL,
                'source'       => NULL,
                'command'      => NULL,
                'content_logs' => NULL,
            ];

            return $outResult;
        }
    }
646611
protected function safeJsonEncode(array $data, $base64 = true)
    {
        foreach ($data as $key => $value) {
            $data[$key] = $this->makeJsonSafe($value, $base64);
        }

        return json_encode($data, JSON_UNESCAPED_SLASHES);
    }
969649
def verify(self, data, signature=None, keyrings=None, homedir=None):
        '''
        
        '''

        if isinstance(data, six.text_type):
            data = data.encode('utf-8')

        tmpdir = tempfile.mkdtemp()
        data_file, data_path = tempfile.mkstemp(dir=tmpdir)
        data_file = os.fdopen(data_file, 'wb')
        data_file.write(data)
        data_file.close()
        if signature:
            sig_file, sig_path = tempfile.mkstemp(dir=tmpdir)
            sig_file = os.fdopen(sig_file, 'wb')
            sig_file.write(signature)
            sig_file.close()
        else:
            sig_path = None
        try:
            return self.verify_from_file(
                data_path,
                sig_path=sig_path,
                keyrings=keyrings,
                homedir=homedir
            )
        finally:
            shutil.rmtree(tmpdir)