简体   繁体   English

使用Google Closure Compiler时如何防止关键字被混淆?

[英]How to prevent keywords from getting obfuscated when using Google Closure Compiler?

I am trying to obfuscate javascript files (Around 50) using the Google Closure compiler. 我正在尝试使用Google Closure编译器来混淆javascript文件(大约50个)。 the files all depend on one another. 这些文件都依赖于彼此。

In simple mode, it obfuscates only local variables. 在简单模式下,它只模糊局部变量。

In advanced mode, it obfuscates all the variables and functions including certain keywords that I do not want to obfuscate(args, readline, atEnd). 在高级模式下,它会混淆所有变量和函数,包括我不想混淆的某些关键字(args,readline,atEnd)。

How can I obfuscate some of the variables but not others? 我怎样才能混淆一些变量而不是其他变量呢? Specifically: I don't want the keywords to get obfuscated. 具体来说:我不希望关键字被混淆。

There is a pretty significant difference between ADVANCED and SIMPLE modes. ADVANCEDSIMPLE模式之间存在非常显着的差异。 Advanced optimizations are only appropriate for code bases which are designed not to violate any of the compiler restrictions . 高级优化仅适用于设计为不违反任何编译器限制的代码库。 Before continuing, you might read Which Compilation Level is Right for Me? 在继续之前,您可能会阅读哪个编译级别适合我?

The answers to your question are externs and exports: 您的问题的答案是外部和出口:

  • Externs prevent the compiler from renaming symbols in external libraries Externs阻止编译器重命名外部库中的符号
  • Exports preserve symbols in your code for use elsewhere 导出会在代码中保留符号以供其他地方使用

I don't have experience with Google Closure Compiler, but to obfuscate my projects I use Jscrambler. 我没有使用Google Closure Compiler的经验,但为了模糊我的项目,我使用的是Jscrambler。 It lets you prevent keywords from being obfuscated using a blacklist that they refer as "Rename Exclude List" . 它允许您使用他们称为“重命名排除列表”的黑名单来防止对关键字进行模糊处理。 I use this feature sometimes when I have delicate function names that otherwise would break my code if they had got obfuscated. 我有时会使用这个功能,因为我有一些功能名称,否则如果它们被混淆就会破坏我的代码。

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

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