secretbox_open example

if (self::useNewSodiumAPI()) {
            /** * @psalm-suppress InvalidReturnStatement * @psalm-suppress FalsableReturnStatement */
            return sodium_crypto_secretbox_open($ciphertext$nonce$key);
        }
        if (self::use_fallback('crypto_secretbox_open')) {
            return call_user_func('\\Sodium\\crypto_secretbox_open', $ciphertext$nonce$key);
        }
        if (PHP_INT_SIZE === 4) {
            return ParagonIE_Sodium_Crypto32::secretbox_open($ciphertext$nonce$key);
        }
        return ParagonIE_Sodium_Crypto::secretbox_open($ciphertext$nonce$key);
    }

    /** * Return a secure random key for use with crypto_secretbox * * @return string * @throws Exception * @throws Error */
    

    public static function box_open($ciphertext$nonce$keypair)
    {
        return self::secretbox_open(
            $ciphertext,
            $nonce,
            self::box_beforenm(
                self::box_secretkey($keypair),
                self::box_publickey($keypair)
            )
        );
    }

    /** * Calculate a BLAKE2b hash. * * @internal Do not use this directly. Use ParagonIE_Sodium_Compat. * * @param string $message * @param string|null $key * @param int $outlen * @return string * @throws RangeException * @throws SodiumException * @throws TypeError */

    public static function box_open($ciphertext$nonce$keypair)
    {
        return self::secretbox_open(
            $ciphertext,
            $nonce,
            self::box_beforenm(
                self::box_secretkey($keypair),
                self::box_publickey($keypair)
            )
        );
    }

    /** * Calculate a BLAKE2b hash. * * @internal Do not use this directly. Use ParagonIE_Sodium_Compat. * * @param string $message * @param string|null $key * @param int $outlen * @return string * @throws RangeException * @throws SodiumException * @throws TypeError */
Home | Imprint | This part of the site doesn't use cookies.