openssl_encrypt

Supported Versions: PHP 5 >= 5.3.0, PHP 7, PHP 8
Encrypts data
<?php openssl_encrypt(    string $data,    string $cipher_algo,    string $passphrase,    int $options = 0,    string $iv = "",    string &$tag = null,    string $aad = "",    int $tag_length = 16): string|false
<?php     {

        $iv = random_bytes(openssl_cipher_iv_length(strtolower($this->cipher)));



        $value = \openssl_encrypt(

            $serialize ? serialize($value) : $value,

            strtolower($this->cipher), $this->key, 0, $iv, $tag

        );



        if ($value === false) {

            throw new EncryptException('Could not encrypt the data.');