public static function encrypt(
        string $plaintext,
        SharedEncryptionKey $key
    ): string {
        $nonce = random_bytes(\ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES);
        return $nonce .
            \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
                $plaintext,
                $nonce,
                $nonce,
                $key->getString(true)
            );
    }
public static function encrypt(
        string $plaintext,
        SharedEncryptionKey $key
    ): string {
        $nonce = random_bytes(\ParagonIE_Sodium_Compat::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES);
        return $nonce .
            \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
                $plaintext,
                $nonce,
                $nonce,
                $key->getString(true)
            );
    }
public static function encrypt ( string $ plaintext , SharedEncryptionKey $ key ) : string { $ nonce = random_bytes ( \ ParagonIE_Sodium_Compat :: CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES ) ; return $ nonce . \ ParagonIE_Sodium_Compat :: crypto_aead_xchacha20poly1305_ietf_encrypt ( $ plaintext , $ nonce , $ nonce , $ key -> getString ( true ) ) ; }
Simple authenticated encryption
XChaCha20-Poly1305

@param string $plaintext
@param SharedEncryptionKey $key
@return string
Simple authenticated encryption XChaCha20 - Poly1305