PHP 7.2+ incorporates Sodium, enabling relatively simple, extremely secure data exchanges.

https://php.watch/articles/modern-php-encryption-decryption-sodium

The example form below generates encrypted text, an encryption key, and a nonce (or vector).
The associated data doesn't get encrypted but is required for authentication and decryption.