@version 1.0
@since   2013-10

@param string $nonce
@param string $createdAt
@param string $password

@return string
3304
public function generateDigest($nonce, $createdAt, $password)
    {
        return base64_encode(sha1(base64_decode($nonce) . $createdAt . $password, true));
    }
1285208
static public function createNoncestr($length = 32, $str = "")
    {
        $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
        for ($i = 0; $i < $length; $i++) {
            $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
        }
        return $str;
    }
1310018
public static String createAuthenticateHeader(final String realm, final String authMethod, final String nonce) {
        val stringBuilder = new StringBuilder("Digest realm=\"")
            .append(realm).append("\",");
        if (StringUtils.isNotBlank(authMethod)) {
            stringBuilder.append("qop=").append(authMethod).append(',');
        }
        return stringBuilder.append("nonce=\"").append(nonce)
            .append("\",opaque=\"").append(createOpaque(realm, nonce))
            .append('"')
            .toString();
    }
1144652
public function verify_nonce($action, $key = '_wpnonce'){
		$nonce = $this->request($key);
		return $nonce && wp_verify_nonce($this->request($key), $action);
	}
194268
public function sodiumSecretBoxOpen($message, $nonce, $key)
    {
        if (in_array($this->libsodiumVersion, ['2', '7'], true)) {
            return sodium_crypto_secretbox_open($message, $nonce, $key);
        }

        throw new CryptoException(self::ERR_NEED_MORE_SALT);
    }
750983
public static function verifyNonce($nonce, $action)
    {
        //Safety check for multiple nonces
        if (is_array($nonce)) {
            $nonce = array_shift($nonce);
        }

        //Nonce generated 0-12 hours ago
        if ($nonce === self::getNonce($action)) {
            return true;
        }

        //Nonce generated 12-24 hours ago
        $previousTick = true;

        return $nonce === self::getNonce($action, $previousTick);
    }
1144670
public function createNonceStr() {
        $chars  = "abcdefghijklmnopqrstuvwxyz0123456789";
        $str    = "";
        for ( $i = 0; $i < self::NONCE_STRING_LENGTH; $i++ ) {
            $str .= substr($chars, mt_rand(0, strlen($chars)-1), 1);
        }

        return $str;
    }
1023040
public static String createNonce() {
        val fmtDate = ZonedDateTime.now(ZoneOffset.UTC).toString();
        val rand = RandomUtils.getNativeInstance();
        val randomInt = rand.nextInt();
        return DigestUtils.md5Hex(fmtDate + randomInt);
    }
464741
public function sodiumSecretBox($message, $nonce, $key)
    {
        if (in_array($this->libsodiumVersion, ['2', '7'], true)) {
            return sodium_crypto_secretbox($message, $nonce, $key);
        }

        throw new CryptoException(self::ERR_NEED_MORE_SALT);
    }
985456
public function checkSignature($signature = null, $timestamp = null, $nonce = null)
    {
        $request = Yii::$app->request;
        $signature === null && $signature = $request->get('signature', '');
        $timestamp === null && $timestamp = $request->get('timestamp', '');
        $nonce === null && $nonce = $request->get('nonce', '');
        $tmpArr = [$this->token, $timestamp, $nonce];
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        return sha1($tmpStr) == $signature;
    }
627111
private function checkMsgSignature($msg_signature, $timestamp, $nonce, $encrypt) {
		return \Yii::$app->security->compareString($this->sign([$this->manager->app->token, $timestamp, $nonce, $encrypt]), $msg_signature);
	}
373920
public function decryptXml($xml, $messageSignature, $timestamp , $nonce)
    {
        $errorCode = $this->getMessageCrypt()->decryptMsg($messageSignature, $timestamp, $nonce, $xml, $xml);
        if ($errorCode) {
            $this->lastError = [
                'errcode' => $errorCode,
                'errmsg' => 'XML数据解密失败!'
            ];
            return false;
        }
        return $xml;
    }
653185
protected function generateNonce( $length = 32 )
    {
        $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        $result = '';
        for ( $i = 0; $i < $length; $i++ )
        {
            $result .= $chars[mt_rand( 0, strlen( $chars ) - 1 )];
        }

        return $result;
    }
41147
public function saveConsumerNonce($nonce)
    {

        $id = $nonce->getConsumer()->getRecordId();
        $value = $nonce->getValue();
        $expires = date("{$this->dateFormat} {$this->timeFormat}", $nonce->expires);
        $sql = "INSERT INTO {$this->dbTableNamePrefix}" . DataConnector::NONCE_TABLE_NAME . ' (consumer_pk, value, expires) VALUES (:id, :value, :expires)';
        $query = $this->db->prepare($sql);
        $query->bindValue('id', $id, PDO::PARAM_INT);
        $query->bindValue('value', $value, PDO::PARAM_STR);
        $query->bindValue('expires', $expires, PDO::PARAM_STR);
        $ok = $query->execute();

        return $ok;

    }
557563
public function createSignature($nonceStr, $time, $url) {
        $str = "jsapi_ticket=%s&noncestr=%s&timestamp=%d&url=%s";
        $result = sprintf($str, $this->getJsApiTicket()->getTicket(), $nonceStr, $time, $url);
        return sha1($result);
    }
440576
public function getStringToSign(RequestInterface $request, $timestamp, $nonce)
    {
        $params = $this->getParamsToSign($request, $timestamp, $nonce);

        // Convert booleans to strings.
        $params = $this->prepareParameters($params);

        // Build signing string from combined params
        $parameterString = new QueryString($params);

        $url = Url::factory($request->getUrl())->setQuery('')->setFragment(null);

        return strtoupper($request->getMethod()) . '&'
             . rawurlencode($url) . '&'
             . rawurlencode((string) $parameterString);
    }
561255
public function generateNonceKey($mixedNonceSalt = null)
    {
        if (!is_string($mixedNonceSalt)) {
            if (is_object($mixedNonceSalt)) {
                $methods = get_class_methods($mixedNonceSalt);
                $mixedNonceSalt = get_class($mixedNonceSalt) . implode("", $methods);
            } elseif (is_array($mixedNonceSalt)) {
                $mixedNonceSalt = json_encode($mixedNonceSalt);
            }
        }

        $strataSalt = Strata::app()->hasConfig('security.salt') ?
            Strata::app()->getConfig('security.salt') :
            crc32(getenv('SERVER_ADDR'));

        return $strataSalt . md5($mixedNonceSalt);
    }