Returns a valid signature for the given nonce.

@param nonce Request nonce
@return Request signature
505729
public synchronized String getSignature(long nonce) {
    return HexEncoder.encode(sha256HMAC.doFinal(buildSignatureData(nonce)))
        .toLowerCase(Locale.ROOT);
  }
462948
def verify_request(self, request, consumer, token):
        """"""

        self._check_version(request)
        self._check_signature(request, consumer, token)
        parameters = request.get_nonoauth_parameters()
        return parameters
752579
private static String createSignature(String     stringToSign,
                                          String     awsSecretKey,
                                          String     algorithm)
            throws SignatureException {

        assert stringToSign != null;
        assert awsSecretKey != null;
        assert algorithm != null;

        String signature;

        try {
            byte[] secretyKeyBytes = awsSecretKey.getBytes(UTF8_CHARSET);
            SecretKeySpec secretKeySpec = new SecretKeySpec(secretyKeyBytes,
                                                            algorithm);
            Mac mac = Mac.getInstance(algorithm);
            mac.init(secretKeySpec);

            byte[] data = stringToSign.getBytes(UTF8_CHARSET);

            byte[] rawHmac = mac.doFinal(data);
            signature = rfc3986Conformance(new String(Codec.base64Encode(rawHmac)));
        } catch (Exception e) {
            throw new SignatureException("Failed to generate HMAC : " +
                                                               e.getMessage());
        }

        return signature;
    }
562086
private function checkSignature($request, $consumer, $token)
    {
        // this should probably be in a different method
        $timestamp = $request instanceof Request
            ? $request->getParameter('oauth_timestamp')
            : null;
        $nonce = $request instanceof Request
            ? $request->getParameter('oauth_nonce')
            : null;

        $this->checkTimestamp($timestamp);
        $this->checkNonce($consumer, $token, $nonce, $timestamp);

        $signature_method = $this->getSignatureMethod($request);

        $signature = $request->getParameter('oauth_signature');
        $valid_sig = $signature_method->checkSignature(
            $request,
            $consumer,
            $token,
            $signature
        );

        if (!$valid_sig) {
            throw new Exception("Invalid signature");
        }
    }
1332819
protected byte[] getBinaryRequestPayload(SignableRequest<?> request) {
        if (SdkHttpUtils.usePayloadForQueryParameters(request)) {
            String encodedParameters = SdkHttpUtils.encodeParameters(request);
            if (encodedParameters == null)
                return new byte[0];

            return encodedParameters.getBytes(UTF8);
        }

        return getBinaryRequestPayloadWithoutQueryParams(request);
    }
446845
public void verify(HttpServletRequest servletRequest, byte[] serializedRequestEnvelope, RequestEnvelope deserializedRequestEnvelope) {
        String baseEncoded64Signature = servletRequest.getHeader(ServletConstants.SIGNATURE_REQUEST_HEADER);
        String signingCertificateChainUrl = servletRequest.getHeader(ServletConstants.SIGNATURE_CERTIFICATE_CHAIN_URL_REQUEST_HEADER);
        if ((baseEncoded64Signature == null) || (signingCertificateChainUrl == null)) {
            throw new SecurityException(
                    "Missing signature/certificate for the provided skill request");
        }

        try {
            X509Certificate signingCertificate;
            if (CERTIFICATE_CACHE.containsKey(signingCertificateChainUrl)) {
                signingCertificate = CERTIFICATE_CACHE.get(signingCertificateChainUrl);
                /*
                 * check the before/after dates on the certificate are still valid for the present
                 * time
                 */
                signingCertificate.checkValidity();
            } else {
                signingCertificate = retrieveAndVerifyCertificateChain(signingCertificateChainUrl);

                // if certificate is valid, then add it to the cache
                CERTIFICATE_CACHE.put(signingCertificateChainUrl, signingCertificate);
            }

            // verify that the request was signed by the provided certificate
            Signature signature = Signature.getInstance(ServletConstants.SIGNATURE_ALGORITHM);
            signature.initVerify(signingCertificate.getPublicKey());
            signature.update(serializedRequestEnvelope);
            if (!signature.verify(Base64.decodeBase64(baseEncoded64Signature
                    .getBytes(ServletConstants.CHARACTER_ENCODING)))) {
                throw new SecurityException(
                        "Failed to verify the signature/certificate for the provided skill request");
            }
        } catch (GeneralSecurityException | IOException ex) {
            throw new SecurityException(
                    "Failed to verify the signature/certificate for the provided skill request",
                    ex);
        }
    }
139959
@Override
    protected Optional<DigestCredentials> retrieveCredentials(final WebContext context) {
        // set the www-authenticate in case of error
        final String nonce = calculateNonce();
        context.setResponseHeader(HttpConstants.AUTHENTICATE_HEADER, "Digest realm=\"" + realm + "\", qop=\"auth\", nonce=\""
            + nonce + "\"");

        return super.retrieveCredentials(context);
    }
32113
public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
    {
        $params = new Collection(array(
            'oauth_consumer_key'     => $this->config['consumer_key'],
            'oauth_nonce'            => $nonce,
            'oauth_signature_method' => $this->config['signature_method'],
            'oauth_timestamp'        => $timestamp,
            'oauth_token'            => $this->config['token'],
            'oauth_version'          => $this->config['version']
        ));
        
        if (array_key_exists('callback', $this->config) == true) {
            $params['oauth_callback'] = $this->config['callback'];
        }
        
        if (array_key_exists('verifier', $this->config) == true) {
            $params['oauth_verifier'] = $this->config['verifier'];
        }

        // Add query string parameters
        $params->merge($request->getQuery());

        // Add POST fields to signing string if required
        if ($this->shouldPostFieldsBeSigned($request))
        {
            $params->merge($request->getPostFields());
        }

        // Sort params
        $params = $params->toArray();
        ksort($params);

        return $params;
    }
1233940
static function getSignature($token, $timestamp, $nonce)
    {
        //排序
        try {
            $array = array($token, $timestamp, $nonce);
            sort($array, SORT_STRING);
            $str = implode($array);
            return sha1($str);
        } catch (\Exception $e) {
            @error_log('getSignature Error: ' . $e->getMessage(), 0);
            return FALSE;
        }
    }
240592
public void validateNonce(ConsumerDetails consumerDetails, long timestamp, String nonce) throws AuthenticationException {
    long nowSeconds = (System.currentTimeMillis() / 1000);
    if ((nowSeconds - timestamp) > getValidityWindowSeconds()) {
      throw new CredentialsExpiredException("Expired timestamp.");
    }
  }
194238
def sign(self, payload):
        
        nonce = str(int(time.time() * 1000))
        package = {'apikey': self.key,
                   'message': {'nonce': nonce, 'payload': payload}}

        signature = hmac.new(self.secret, json.dumps(payload).hexdigest,
                             hashlib.sha512).hexdigest()
        package['signature'] = signature

        return json.dumps(package)
940240
public function validSignature($signature, $timestamp, $nonce)
    {
        if ((null == $this->tokenString) || (empty($this->tokenString))) {
            throw new Exception("error token string");
        }

        $data = array($this->tokenString, $timestamp, $nonce);
        // use SORT_STRING rule
        sort($data, SORT_STRING);
        $validStr   = '';

        foreach ($data as $v) {
            $validStr .= $v;
        }

        $validStr = sha1($validStr);
        return ($validStr === $signature);
    }
365699
public static Map<String, String> buildSignAfterParasMap(Map<String, String> params, String paternerKey) {
		params.put("nonce_str", String.valueOf(System.currentTimeMillis()));
		String sign = PaymentKit.createSign(params, paternerKey);
		params.put("sign", sign);
		return params;
	}
184600
protected function create_nonce($length = 32) {
		$nonce = "";
		$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
		$codeAlphabet.= "0123456789";
		for ($i = 0; $i < $length; $i++) {
			$nonce .= $codeAlphabet[$this->crypto_rand_secure(0, strlen($codeAlphabet))];
		}
		return $nonce;
	}
763271
public function verifyClientNonce($cnonce)
    {
        $cnonce_cache_key = 'cnonce__'.$cnonce;

        if (empty($this->cache)) {
            return;
        }

        $cnonce_data = $this->cache->get($cnonce_cache_key);
        if ($cnonce_data == 'USED') {
            throw new NonceException('That nonce has already been used');
        }

        $this->cache->add($cnonce_cache_key, 'USED');
    }
1085915
def request_token(self, board):
    '''
    '''
    nonce = str(uuid.uuid4())

    data = {'scopes': 'write',
            'client_id': self.client_id,
            'application_name': 'HelpMe',
            'public_key': self.public_key.replace("'",""),
            'nonce': nonce }

    url = (board + "/user-api-key/new?scopes=write&application_name=HelpMe&public_key=" + 
           self.public_key.replace("'", "") + 
           "&client_id=" + self.client_id +
           "&nonce=" + nonce )

    bot.newline()
    bot.info('Open browser to:')
    bot.info(url)
    bot.newline()
    
    # the user will open browser, get a token, and then have it saved here.
    bot.info('Copy paste token, press Ctrl-D to save it:')

    lines = []

    # The message is multiple lines
    while True:
        try:
            line = enter_input()
        except EOFError:
            break
        if line:
            lines.append(line)

    message = "\n".join(lines)

    # Write to temporary file, we only need to get key
    tmpfile = mktemp()
    with open(tmpfile, 'w') as filey:
        filey.write(message)

    # Read in again, and get token **important** is binary
    with open(tmpfile, 'rb') as filey:
        message = filey.read()

    # uses pycryptodome (3.7.2)
    cipher = Cipher_PKCS1_v1_5.new(self.key)
    decrypted = json.loads(cipher.decrypt(b64decode(message), None).decode())

    # Validate nonce is in response
    if "nonce" not in decrypted:
        bot.exit('Missing nonce field in response for token, invalid.')

    # Must return nonce that we sent
    if decrypted['nonce'] != nonce:
        bot.exit('Invalid nonce, exiting.')

    return decrypted['key']
970324
public static boolean verify(String appId, String appSecretKey, byte[] body, HttpServletRequest request)
            throws IOException {
        HmacSignatureBuilder builder = new HmacSignatureBuilder();

        String signitSignature = request.getHeader("X-Signit-Signature");
        builder.scheme(request.getHeader("X-Signit-Scheme"))
                .apiKey(appId)
                .apiSecret(appSecretKey.getBytes())
                .method(request.getMethod()
                        .toUpperCase())
                .payload(body)
                .contentType(request.getContentType())
                .host(Validator.isEmpty(request.getHeader("X-Signit-Host")) ? "" : request.getHeader("X-Signit-Host"))
                .resource(Validator.isEmpty(request.getHeader("X-Signit-Resource")) ? ""
                        : request.getHeader("X-Signit-Resource"))
                .nonce(Validator.isEmpty(request.getHeader("X-Signit-Nonce")) ? ""
                        : request.getHeader("X-Signit-Nonce"))
                .date(Validator.isEmpty(request.getHeader("X-Signit-Date")) ? "" : request.getHeader("X-Signit-Date"));
        String selfBuiltHmac = builder.getDefaultAlgorithm() + " " + appId + ":" + builder.buildAsBase64();
        return selfBuiltHmac.equals(signitSignature);
    }