$secret_key = "This is my SeCrEt key";
$method = "AES-256-CBC";
$iv_length = openssl_cipher_iv_length($method);
$iv = openssl_random_pseudo_bytes($iv_length);
$data = "page=homepage";
$encrypted = openssl_encrypt($data, $method, $secret_key, OPENSSL_RAW_DATA, $iv);
// Guardar IV + datos cifrados juntos
$final_output = base64_encode($iv . $encrypted);
$final_output = urlencode($final_output); // Para usar en un link