Summery Summery
Anonymous public-key encryption. Only the recipient may decrypt messages.
Syntax Syntax
Description Description
Algorithm: X25519-XSalsa20-Poly1305, as with crypto_box. The sender’s X25519 keypair is ephemeral. Nonce is generated from the BLAKE2b hash of both public keys.
This provides ciphertext integrity.
Parameters Parameters
- $plaintext
-
(Required) Message to be sealed
- $publicKey
-
(Required) Your recipient's public key
Return Return
(string) Sealed message that only your recipient can decrypt
Source Source
File: wp-includes/sodium_compat/src/Compat.php
public static function crypto_box_seal($plaintext, $publicKey) { /* Type checks: */ ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1); ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2); /* Input validation: */ if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_BOX_PUBLICKEYBYTES) { throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.'); } if (self::useNewSodiumAPI()) { return (string) sodium_crypto_box_seal($plaintext, $publicKey); } if (self::use_fallback('crypto_box_seal')) { return (string) call_user_func('\\Sodium\\crypto_box_seal', $plaintext, $publicKey); } if (PHP_INT_SIZE === 4) { return ParagonIE_Sodium_Crypto32::box_seal($plaintext, $publicKey); } return ParagonIE_Sodium_Crypto::box_seal($plaintext, $publicKey); }