@param string $message
@param string $nonce
@param string $key

@return string
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);
    }
641223
public function decrypt($data, $key = null, $nonce = null)
    {
        $plain = parent::decrypt($data, $key, $nonce);

        $key = (string) $key;
        $nonce = (string) $nonce;

        $this->memzero($data);
        $this->memzero($key);
        $this->memzero($nonce);

        return $plain;
    }
866081
public function withDetail($key, $message)
    {
        assert(!is_null($key), 'Key must not be null');
        assert(!is_null($message), 'Message must not be null');
        $this->details[strval($key)] = $message;

        return $this;
    }
1144652
public function verify_nonce($action, $key = '_wpnonce'){
		$nonce = $this->request($key);
		return $nonce && wp_verify_nonce($this->request($key), $action);
	}
132613
public function addMessageNow($key, $message)
    {
        // Create Array for this key
        if (!isset($this->forNow[$key])) {
            $this->forNow[$key] = [];
        }

        // Push onto the array
        $this->forNow[$key][] = $message;
    }
898538
public function getMessage($key) {
        if (!$this->_loaded) $this->load();
        if (!isset($this->messages[$key])) return "[$key]";
        return $this->messages[$key];
    }
667118
private function getRegistry($nonce)
    {
        if (null === $registry = $this->registryRepository->findOneBy(['key' => $nonce, 'scope' => 'SECURITY.NONCE'])) {
            $registry = new Registry();
            $registry->setKey($nonce)->setScope('SECURITY.NONCE');
        }

        return $registry;
    }
717330
public function write($key, $message)
    {
        $message = strval($message);
        return (strlen($key) && strlen($message))
            ? $this->_getCipherOb($key)->encrypt($message)
            : '';
    }
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;

    }
1098031
public function auth($nonce = null, $params = null)
    {
        $params = $params ?: array();

        $client_id = $this->params['client_id'];
        $client_key = $this->params['client_key'];

        // 1) Get nonce
        $nonce = $nonce ?: $this->server->request('auth');

        // 2) Create key hash
        $key_hash = md5("{$client_id}::{$client_key}");

        // 3) Create auth key
        $auth_key = md5("{$nonce}{$client_id}{$key_hash}");

        // 4) Authenticate with client params
        $params['client'] = $client_id;
        $params['key'] = $auth_key;

        if ($this->params['version']) {
            $params['$v'] = $this->params['version'];
        }
        if ($this->params['api']) {
            $params['$api'] = $this->params['api'];
        }
        if ($this->params['session']) {
            $params['$session'] = $this->params['session'];
        }
        if (isset($this->params['route']['client'])) {
            $params['$route'] = $this->params['route'];
        }
        if (isset($_SERVER['REMOTE_ADDR']) && $ip_address = $_SERVER['REMOTE_ADDR']) {
            $params['$ip'] = $ip_address;
        }
        if ($this->cache) {
            $params['$cached'] = $this->cache->get_versions();
        }

        $this->authed = true;
        
        try {
            return $this->server->request('auth', $params);
        } catch (NetworkException $e) {
            $this->request_rescue($e);
            return $this->auth();
        }
    }
770300
public byte[] sign(byte[] nonce) {
        try {
            char[] keyChars = this.readKeyChars();
            NKey nkey =  NKey.fromSeed(keyChars);
            byte[] sig = nkey.sign(nonce);
            nkey.clear();
            return sig;
        } catch (Exception exp) {
            throw new IllegalStateException("problem signing nonce", exp);
        }
    }
312498
public function decrypt($message)
    {
        $data = \base64_decode($message, true);

        if ($data === false)
        {
            throw new Exceptions\Invalid('Invalid `message` on decrypt');
        }

        $nonceSize  = \openssl_cipher_iv_length($this->method);
        $nonce      = \mb_substr($data, 0, $nonceSize, '8bit');
        $cipherText = \mb_substr($data, $nonceSize, null, '8bit');

        $plaintext = \openssl_decrypt(
            $cipherText,
            $this->method,
            $this->password,
            OPENSSL_RAW_DATA,
            $nonce
        );

        return $plaintext;
    }
808065
function toMessage($message, $request = null)
    {
        $implicit = $message->isOpenID1();
        $added = $message->namespaces->addAlias($this->ns_uri,
                                                $this->ns_alias,
                                                $implicit);

        if ($added === null) {
            if ($message->namespaces->getAlias($this->ns_uri) !=
                $this->ns_alias) {
                return null;
            }
        }

        if ($request !== null) {
            $message->updateArgs($this->ns_uri,
                                 $this->getExtensionArgs($request));
        } else {
            $message->updateArgs($this->ns_uri,
                                 $this->getExtensionArgs());
        }
        return $message;
    }
558274
protected function readNonceValue($nonce)
    {
        $value = null;

        if (null === $this->registryRepository) {
            if (true === is_readable($this->nonceDir.DIRECTORY_SEPARATOR.$nonce)) {
                $value = file_get_contents($this->nonceDir.DIRECTORY_SEPARATOR.$nonce);
            }
        } else {
            $value = $this->getRegistry($nonce)->getValue();
        }

        if (null !== $value) {
            $value = explode(';', $value);
        }

        return $value;
    }
609785
private function encryptBody(string $request, string $publicKey, string $nonce) : string
    {
        if (\strlen($publicKey) !== SODIUM_CRYPTO_BOX_PUBLICKEYBYTES) {
            throw new InvalidArgumentException(sprintf("Public key should be %d bytes.", SODIUM_CRYPTO_BOX_PUBLICKEYBYTES));
        }

        if (\strlen($nonce) !== SODIUM_CRYPTO_BOX_NONCEBYTES) {
            throw new InvalidArgumentException(sprintf("Nonce should be %d bytes.", SODIUM_CRYPTO_BOX_NONCEBYTES));
        }

        try {
            $keypair = new Keypair(
                $this->secretKey,
                $publicKey
            );
            return \sodium_crypto_box(
                $request,
                $nonce,
                $keypair->getSodiumKeypair()
            );
        } catch (SodiumException $e) {
            throw new InvalidArgumentException($e->getMessage());
        }
    }
1153503
public static function decrypt(
        string $ciphertext,
        SharedEncryptionKey $key
    ): string {
        $nonce = \ParagonIE_Sodium_Core_Util::substr($ciphertext, 0, 24);
        $result = \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt(
            \ParagonIE_Sodium_Core_Util::substr($ciphertext, 24),
            $nonce,
            $nonce,
            $key->getString(true)
        );
        if (!\is_string($result)) {
            throw new InvalidMessageException('Message authentication failed.');
        }
        return $result;
    }
836033
public function loadConsumerNonce($nonce) {
        global $DB;

        // Delete any expired nonce values.
        $now = time();
        $DB->delete_records_select($this->noncetable, "expires <= ?", [$now]);

        // Load the nonce.
        $params = [
            'consumerid' => $nonce->getConsumer()->getRecordId(),
            'value' => $nonce->getValue()
        ];
        $result = $DB->get_field($this->noncetable, 'value', $params);

        return !empty($result);
    }