Verifies and stores a client nonce.

Throws a NonceException if the nonce does not verify (has been used).

@param string $cnonce The client nonce key.

@throws NonceException
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');
    }
696989
public Payload setNonce(String nonce) {
        this.nonce = nonce;
        this.put(PayloadConstants.NONCE, nonce);
        return this;
    }
1273696
private function check_signature($request, $consumer, $token)
    {
        // this should probably be in a different method
        $timestamp = $request instanceof Twitter_OAuthRequest
            ? $request->get_parameter('oauth_timestamp')
            : null;
        $nonce = $request instanceof Twitter_OAuthRequest
            ? $request->get_parameter('oauth_nonce')
            : null;

        $this->check_timestamp($timestamp);
        $this->check_nonce($consumer, $token, $nonce, $timestamp);

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

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

        if (!$valid_sig) {
            throw new Twitter_OAuthException('Invalid signature');
        }
    }
910843
function setKey($key) {
		$this->cnxn->confirmTransaction('setKey');
		$currKey = $this->key;
		if (!is_null($currKey) && is_null($key)) {
			$this->cnxn->unregisterStructWithKey($this, $currKey);
		} else if (is_null($currKey) && !is_null($key)) {
			$this->cnxn->registerStructWithKey($this, $key);
		} else if ($currKey != $key) {
			$this->cnxn->unregisterStructWithKey($this, $currKey);
			$this->cnxn->registerStructWithKey($this, $key);
		}
		$this->key = $key;
	}
377272
func (s *ThirdPartyJobDetails) SetNonce(v string) *ThirdPartyJobDetails {
	s.Nonce = &v
	return s
}
142202
public function verifyIPN($url, $signature, $key, $nonce, $body)
    {
        if (!$key || !$nonce || !$signature || $body == "") {
            //// missing headers OR an empty payload
            return false;
        }
        $message = $nonce . $url . $body;
        $calculated_signature = $this->signMessage($message);
        if($calculated_signature <> $signature ){
            //// invalid IPN call
            return false;
        }
        //// valid IPN call
        return true;
    }
1018565
private function _getCnonce()
    {
        // TODO: I reused the nonce function from the DigestMD5 class.
        // I should probably make this a protected function in Common.
        if (@file_exists('/dev/urandom') && $fd = @fopen('/dev/urandom', 'r')) {
            return base64_encode(fread($fd, 32));

        } elseif (@file_exists('/dev/random') && $fd = @fopen('/dev/random', 'r')) {
            return base64_encode(fread($fd, 32));

        } else {
            $str = '';
            for ($i=0; $i<32; $i++) {
                $str .= chr(mt_rand(0, 255));
            }

            return base64_encode($str);
        }
    }
157755
public static function setCacheTimesForAuthRecheck($n)
    {
        phpCAS::_validateClientExists();

        try {
            self::$_PHPCAS_CLIENT->setCacheTimesForAuthRecheck($n);
        } catch (Exception $e) {
            phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
        }
    }
601242
protected function getNonceValue()
    {
        if (null === $this->nonce) {
            $this->nonce = new Nonce();
        }
        return $this->nonce->generate();
    }
1148093
public function loadConsumerNonce($nonce)
    {

        $ok = true;

// Delete any expired nonce values
        $now = date("{$this->dateFormat} {$this->timeFormat}", time());
        $sql = "DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::NONCE_TABLE_NAME . " WHERE expires <= '{$now}'";
        mysql_query($sql);

// Load the nonce
        $sql = sprintf("SELECT value AS T FROM {$this->dbTableNamePrefix}" . DataConnector::NONCE_TABLE_NAME . ' WHERE (consumer_pk = %d) AND (value = %s)',
                       $nonce->getConsumer()->getRecordId(), DataConnector::quoted($nonce->getValue()));
        $rs_nonce = mysql_query($sql);
        if ($rs_nonce) {
            $row = mysql_fetch_object($rs_nonce);
            if ($row === false) {
                $ok = false;
            }
        }

        return $ok;

    }
912691
public function remove($nameOrInstance)
    {
        if (is_callable($nameOrInstance)) {
            $this->removeByInstance($nameOrInstance);
        } elseif (is_string($nameOrInstance)) {
            $this->removeByName($nameOrInstance);
        }
    }
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);
    }
396869
public function loadConsumerNonce($nonce)
    {

        $ok = true;

// Delete any expired nonce values
        $now = date("{$this->dateFormat} {$this->timeFormat}", time());
        $sql = "DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::NONCE_TABLE_NAME . ' WHERE expires <= :now';
        $query = $this->db->prepare($sql);
        $query->bindValue('now', $now, PDO::PARAM_STR);
        $query->execute();

// Load the nonce
        $id = $nonce->getConsumer()->getRecordId();
        $value = $nonce->getValue();
        $sql = "SELECT value T FROM {$this->dbTableNamePrefix}" . DataConnector::NONCE_TABLE_NAME . ' WHERE (consumer_pk = :id) AND (value = :value)';
        $query = $this->db->prepare($sql);
        $query->bindValue('id', $id, PDO::PARAM_INT);
        $query->bindValue('value', $value, PDO::PARAM_STR);
        $ok = $query->execute();
        if ($ok) {
            $row = $query->fetch(PDO::FETCH_ASSOC);
            if ($row === false) {
                $ok = false;
            }
        }

        return $ok;

    }
1031971
private function cspGenerateNonce()
    {
        $nonce = base64_encode(
            openssl_random_pseudo_bytes(30, $isCryptoStrong)
        );

        if ( ! $isCryptoStrong)
        {
            $this->addError(
                'OpenSSL (openssl_random_pseudo_bytes) reported that it did
                <strong>not</strong> use a cryptographically strong algorithm
                to generate the nonce for CSP.',

                E_USER_WARNING
            );
        }

        return $nonce;
    }
855280
protected function validNonce($nonce)
    {
        $value = base64_decode($nonce);
        if ($value === false) {
            return false;
        }
        $parts = explode(':', $value);
        if (count($parts) !== 2) {
            return false;
        }
        list($expires, $checksum) = $parts;
        if ($expires < microtime(true)) {
            return false;
        }
        $secret = $this->getConfig('secret');
        $check = hash_hmac('sha1', $expires . ':' . $secret, $secret);

        return hash_equals($check, $checksum);
    }
878689
public static function addNonce($url, $action, $nonceParamName = 'nonce')
    {
        $fake = $url && strpos($url, '/') === 0;

        if ($fake) {
            $url = 'http://domain.com' . $url;
        }
        $uri = new static($url);
        $parts = $uri->toArray();
        $nonce = Utils::getNonce($action);
        $parts['params'] = ($parts['params'] ?? []) + [$nonceParamName => $nonce];

        if ($fake) {
            unset($parts['scheme'], $parts['host']);
        }

        return static::buildUrl($parts);
    }
25339
def validate_nonce(nonce, secret):
    '''
    
    '''
    nonce_components = nonce.split(':', 2)
    if not len(nonce_components) == 3:
        return False
    timestamp = nonce_components[0]
    salt = nonce_components[1]
    nonce_signature = nonce_components[2]

    calculated_nonce = calculate_nonce(timestamp, secret, salt)

    if not nonce == calculated_nonce:
        return False

    return True