简体   繁体   English

将PHP与混淆的JS混合

[英]Mixing PHP with obfuscated JS

I am looking at obfuscating my JS code, however some parts of my JS code is generated from PHP logic. 我正在看混淆我的JS代码,但是我的JS代码的某些部分是从PHP逻辑生成的。

One example would be the following: 下面是一个示例:

<?php if ($somethingFromPHP == true){ ?>
        A_JS_Variable_Already_Obfuscated = true;
        A_JS_Function_Already_obfuscated('<?php echo json_encode($anotherThingFromPHP); ?>');
<?php } ?>

As you can see, there is a conflict with that code. 如您所见,该代码存在冲突。

My PHP code is unaware of the obfuscated variable and function. 我的PHP代码没有意识到混淆的变量和函数。

How would I solve this conflict? 我将如何解决这一冲突?

I recommend parsing the javascript with the PHP first, then running that file through a minifier and obfuscater. 我建议先使用PHP解析javascript,然后通过minifier和obfuscater运行该文件。 Or alternatively running the php separately, and taking the php output and inserting it into the javascript using commandline tools such as sed and awk , then running it through the minifier and obfuscater. 或者,也可以单独运行php,然后使用sedawk等命令行工具获取php输出并将其插入到javascript中,然后通过minifier和obfuscater运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM