ParagonIE_Sodium_Compat::crypto_box_open() public WP 1.0
Decrypt a message previously encrypted with crypto_box().
{} It's a method of the class: ParagonIE_Sodium_Compat{}
No Hooks.
Return
String
. The original plaintext message
Usage
$result = ParagonIE_Sodium_Compat::crypto_box_open( $ciphertext, $nonce, $keypair );
- $ciphertext(string) (required)
- Encrypted message
- $nonce(string) (required)
- Number to only be used Once; must be 24 bytes
- $keypair(string) (required)
- Your secret key and the sender's public key
Code of ParagonIE_Sodium_Compat::crypto_box_open() ParagonIE Sodium Compat::crypto box open WP 5.7
public static function crypto_box_open($ciphertext, $nonce, $keypair)
{
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2);
ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 3);
/* Input validation: */
if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_BOX_MACBYTES) {
throw new SodiumException('Argument 1 must be at least CRYPTO_BOX_MACBYTES long.');
}
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_BOX_NONCEBYTES) {
throw new SodiumException('Argument 2 must be CRYPTO_BOX_NONCEBYTES long.');
}
if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== self::CRYPTO_BOX_KEYPAIRBYTES) {
throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
}
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
*/
return sodium_crypto_box_open($ciphertext, $nonce, $keypair);
}
if (self::use_fallback('crypto_box_open')) {
return call_user_func('\\Sodium\\crypto_box_open', $ciphertext, $nonce, $keypair);
}
if (PHP_INT_SIZE === 4) {
return ParagonIE_Sodium_Crypto32::box_open($ciphertext, $nonce, $keypair);
}
return ParagonIE_Sodium_Crypto::box_open($ciphertext, $nonce, $keypair);
}