WordPress at Your Fingertips
function is not described

ParagonIE_Sodium_Crypto::box_seal() public WP 1.0

X25519-XSalsa20-Poly1305 with one ephemeral X25519 keypair.

{} It's a method of the class: ParagonIE_Sodium_Crypto{}

No Hooks.

Return

String.

Usage

$result = ParagonIE_Sodium_Crypto::box_seal( $message, $publicKey );
$message(string) (required)
-
$publicKey(string) (required)
-

Code of ParagonIE_Sodium_Crypto::box_seal() WP 5.8.2

public static function box_seal($message, $publicKey)
{
    /** @var string $ephemeralKeypair */
    $ephemeralKeypair = self::box_keypair();

    /** @var string $ephemeralSK */
    $ephemeralSK = self::box_secretkey($ephemeralKeypair);

    /** @var string $ephemeralPK */
    $ephemeralPK = self::box_publickey($ephemeralKeypair);

    /** @var string $nonce */
    $nonce = self::generichash(
        $ephemeralPK . $publicKey,
        '',
        24
    );

    /** @var string $keypair - The combined keypair used in crypto_box() */
    $keypair = self::box_keypair_from_secretkey_and_publickey($ephemeralSK, $publicKey);

    /** @var string $ciphertext Ciphertext + MAC from crypto_box */
    $ciphertext = self::box($message, $nonce, $keypair);
    try {
        ParagonIE_Sodium_Compat::memzero($ephemeralKeypair);
        ParagonIE_Sodium_Compat::memzero($ephemeralSK);
        ParagonIE_Sodium_Compat::memzero($nonce);
    } catch (SodiumException $ex) {
        $ephemeralKeypair = null;
        $ephemeralSK = null;
        $nonce = null;
    }
    return $ephemeralPK . $ciphertext;
}