public static function encrypt(string $data, string $key): string
    {
        $method = Configuration::getSecurityConfiguration('encryption_algorithm');
        $initializationVector = self::randomBytes(openssl_cipher_iv_length($method));
        $cipher = openssl_encrypt($data, $method, $key, 0, $initializationVector);
        return base64_encode($initializationVector) . ':' . base64_encode($cipher);
    }
public static function encrypt(string $data, string $key): string
    {
        $method = Configuration::getSecurityConfiguration('encryption_algorithm');
        $initializationVector = self::randomBytes(openssl_cipher_iv_length($method));
        $cipher = openssl_encrypt($data, $method, $key, 0, $initializationVector);
        return base64_encode($initializationVector) . ':' . base64_encode($cipher);
    }
public static function encrypt ( string $ data , string $ key ) : string { $ method = Configuration :: getSecurityConfiguration ( 'encryption_algorithm' ) ; $ initializationVector = self :: randomBytes ( openssl_cipher_iv_length ( $ method ) ) ; $ cipher = openssl_encrypt ( $ data , $ method , $ key , 0 , $ initializationVector ) ; return base64_encode ( $ initializationVector ) . ':' . base64_encode ( $ cipher ) ; }
Encrypts the given data using the configured encryption algorithm and
the provided key. Returns a concatenation of the generated IV and the
cipher. Resulting cipher should only be decrypted using the decrypt
method.

@param string $data
@param string $key
@return string
Encrypts the given data using the configured encryption algorithm and the provided key . Returns a concatenation of the generated IV and the cipher . Resulting cipher should only be decrypted using the decrypt method .