Verify an HMAC signature
@internal used by `.verify()`
@param  {Buffer} signature
@param  {Buffer} input
@param  {Buffer} key
@return {Boolean}
194932
function( signature, input, key ) {

    var check = this.sign( input, key )

    return signature.toString( 'hex' ) ===
      check.toString( 'hex' )

  }
709701
public static boolean isMacValid(byte[] expected, byte[] input, byte[] key) {
		byte[] actual = hmacSha1(input, key);
		return Arrays.equals(expected, actual);
	}
494260
function (message, signature) {
      var md = forge.md.sha1.create();
      md.update(message, 'utf8');
      try {
        return this._cert.publicKey.verify(md.digest().bytes(), forge.util.decode64(signature));
      } catch (e) {
        return false;
      }
    }
272547
public boolean verify(String message, String signature) {
		try {
			return verifier.verify(message.getBytes(charsetName), Base64.decodeBase64(signature));
		} catch (UnsupportedEncodingException e) {
			throw new SignatureException("unsupported encoding: charsetName=" + charsetName, e);
		} catch (Exception e) {
			return false;
		}
	}
194518
function SigCacheEntry(sig, key) {
  this.sig = Buffer.from(sig);
  this.key = Buffer.from(key);
}
1177768
function signHMAC(token, random) {
    var hmac = createHmac('sha256', random);
    let sig = hmac.update(token).digest('hex');
    return sig;
}
116638
def _compute_signature(parameters, access_key_secret, method, path):
    '''
    
    '''
    parameters['signature_method'] = 'HmacSHA256'

    string_to_sign = '{0}\n{1}\n'.format(method.upper(), path)

    keys = sorted(parameters.keys())
    pairs = []
    for key in keys:
        val = six.text_type(parameters[key]).encode('utf-8')
        pairs.append(_quote(key, safe='') + '=' + _quote(val, safe='-_~'))
    qs = '&'.join(pairs)
    string_to_sign += qs

    h = hmac.new(access_key_secret, digestmod=sha256)
    h.update(string_to_sign)

    signature = base64.b64encode(h.digest()).strip()

    return signature
901421
public static function verify($token, $signature, $key, $algorithm = 'HS256')
    {
        $segments = explode('.', $token);
        $segments = array_map('trim', $segments);

        if (count($segments) == 3) {
            array_pop($segments);
            $data = implode('.', $segments);

            if (Algorithm::validate($algorithm)) {
                list($function, $algorithm) = Algorithm::map($algorithm);

                switch ($function) {
                    case 'HMAC':
                        return Hmac::hash($algorithm, $data, $key, true) === $signature;
                    case 'hash_hmac':
                        return hash_hmac($algorithm, $data, $key, true) === $signature;
                    case 'openssl':
                        switch ($algorithm) {
                            case 'RS256':
                                return (bool)openssl_verify($data, $signature, $key, OPENSSL_ALGO_SHA1);
                            case 'RS256':
                                return (bool)openssl_verify($data, $signature, $key, OPENSSL_ALGO_SHA256);
                            case 'RS384':
                                return (bool)openssl_verify($data, $signature, $key, OPENSSL_ALGO_SHA384);
                            case 'RS512':
                                return (bool)openssl_verify($data, $signature, $key, OPENSSL_ALGO_SHA512);
                        }
                }
            }
        }

        return false;
    }
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;
}
129208
def sign(self, msg, key):
        
        h = hmac.HMAC(key, self.algorithm(), default_backend())
        h.update(msg)
        return h.finalize()
98667
def verify_signature(key, qs):
    """"""
    unsigned_qs = re.sub(r'&?sig=[^&]*', '', qs)
    sig = derive_signature(key, unsigned_qs)
    return urlparse.parse_qs(qs).get("sig", [None])[0] == sig
859995
def _verify_multi(self, token, verifying_keys, num_required=None):
        
        headers, payload, raw_signatures, signing_inputs = _unpack_token_json(token)
        if num_required is None:
            num_required = len(raw_signatures)

        if num_required > len(verifying_keys):
            # not possible
            return False

        if len(headers) != len(raw_signatures):
            # invalid 
            raise DecodeError('Header/signature mismatch')

        verifying_keys = [load_verifying_key(vk, self.crypto_backend) for vk in verifying_keys]

        # sanity check: only support one type of key :(
        for vk in verifying_keys:
            if vk.curve.name != verifying_keys[0].curve.name:
                raise DecodeError("TODO: only support using keys from one curve per JWT")
                
        der_signatures = [raw_to_der_signature(rs, verifying_keys[0].curve) for rs in raw_signatures]

        # verify until threshold is met
        num_verified = 0
        for (signing_input, der_sig) in zip(signing_inputs, der_signatures):
            for vk in verifying_keys:
                verifier = self._get_verifier(vk, der_sig)
                verifier.update(signing_input)
                try:
                    verifier.verify()
                    num_verified += 1
                    verifying_keys.remove(vk)
                    break
                except InvalidSignature:
                    pass

            if num_verified >= num_required:
                break

        return (num_verified >= num_required)
964068
function verify(key, value) {
  var method = validator[key];
  if(typeof method === 'function') {
    // this will throw the error if verification fails
    // invert argument order as validator methods are more
    // interested in the value than the key
    value = method(value, key);
    if(value !== undefined) {
      this.set(key, value, null, true);
    }
  }

  return value;
}
764517
function publicKeyVerify(key) {
  if (key.length === 0)
    return false;

  switch (key[0]) {
    case 0x02:
    case 0x03:
      return key.length === 33;
    case 0x04:
      if (key.length !== 65)
        return false;

      return secp256k1.publicKeyVerify(key);
    default:
      return false;
  }
}
677803
public static boolean verify(byte[] data, String publicKey, String sign) throws Exception {
        String keyBytes = Base64Utils.encode(publicKey);
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes.getBytes());
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
        PublicKey publicK = keyFactory.generatePublic(keySpec);
        Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
        signature.initVerify(publicK);
        signature.update(data);
        return signature.verify(Base64Utils.decode(sign).getBytes());
    }
473449
function hmacSha256(key, data) {
    if (subtle) {
        var algo = { name: 'HMAC', hash: { name: 'SHA-256' } };
        return subtle.importKey('raw', key, algo, false, ['sign'])
            .then(function(subtleKey) {
                return subtle.sign(algo, subtleKey, data);
            });
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var hmac = nodeCrypto.createHmac('sha256', Buffer.from(key));
            var hash = hmac.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'HMAC-SHA256 not implemented'));
    }
}
297938
public static boolean validateSign(Map<String,String> map,String key){
		return validateSign(map, null, key);
	}