ParagonIE_Sodium_Compat::crypto_box_seal() public WP 1.0
Anonymous public-key encryption. Only the recipient may decrypt messages.
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.
{} It's a method of the class: ParagonIE_Sodium_Compat{}
No Hooks.
Return
String
. Sealed message that only your recipient can decrypt
Usage
$result = ParagonIE_Sodium_Compat::crypto_box_seal( $plaintext, $publicKey );
- $plaintext(string) (required)
- Message to be sealed
- $publicKey(string) (required)
- Your recipient's public key
Code of ParagonIE_Sodium_Compat::crypto_box_seal() ParagonIE Sodium Compat::crypto box seal WP 5.7
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);
}