public static function seal(
        string $plaintext,
        SealingPublicKey $publicKey
    ): string {
        $ephemeralSecret = SealingSecretKey::generate();
        $sharedSecret = static::keyExchange(
            $ephemeralSecret,
            $publicKey,
            false,
            56
        );
        $ephemeralPublicKey = $ephemeralSecret->getPublickey()->getString(true);
        $sharedKey = \ParagonIE_Sodium_Core_Util::substr($sharedSecret, 0, 32);
        $nonce = \ParagonIE_Sodium_Core_Util::substr($sharedSecret, 32, 24);
        try {
            \ParagonIE_Sodium_Compat::memzero($sharedSecret);
        } catch (\Throwable $ex) {
        }

        return $ephemeralPublicKey. \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
            $plaintext,
            $ephemeralPublicKey,
            $nonce,
            $sharedKey
        );
    }
public static function seal(
        string $plaintext,
        SealingPublicKey $publicKey
    ): string {
        $ephemeralSecret = SealingSecretKey::generate();
        $sharedSecret = static::keyExchange(
            $ephemeralSecret,
            $publicKey,
            false,
            56
        );
        $ephemeralPublicKey = $ephemeralSecret->getPublickey()->getString(true);
        $sharedKey = \ParagonIE_Sodium_Core_Util::substr($sharedSecret, 0, 32);
        $nonce = \ParagonIE_Sodium_Core_Util::substr($sharedSecret, 32, 24);
        try {
            \ParagonIE_Sodium_Compat::memzero($sharedSecret);
        } catch (\Throwable $ex) {
        }

        return $ephemeralPublicKey. \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
            $plaintext,
            $ephemeralPublicKey,
            $nonce,
            $sharedKey
        );
    }
public static function seal ( string $ plaintext , SealingPublicKey $ publicKey ) : string { $ ephemeralSecret = SealingSecretKey :: generate ( ) ; $ sharedSecret = static :: keyExchange ( $ ephemeralSecret , $ publicKey , false , 56 ) ; $ ephemeralPublicKey = $ ephemeralSecret -> getPublickey ( ) -> getString ( true ) ; $ sharedKey = \ ParagonIE_Sodium_Core_Util :: substr ( $ sharedSecret , 0 , 32 ) ; $ nonce = \ ParagonIE_Sodium_Core_Util :: substr ( $ sharedSecret , 32 , 24 ) ; try { \ ParagonIE_Sodium_Compat :: memzero ( $ sharedSecret ) ; } catch ( \ Throwable $ ex ) { } return $ ephemeralPublicKey . \ ParagonIE_Sodium_Compat :: crypto_aead_xchacha20poly1305_ietf_encrypt ( $ plaintext , $ ephemeralPublicKey , $ nonce , $ sharedKey ) ; }
Encrypt a message with a public key, so that it can only be decrypted
with the corresponding secret key.

@param string $plaintext
@param SealingPublicKey $publicKey
@return string
Encrypt a message with a public key so that it can only be decrypted with the corresponding secret key .