【问题标题】:Securing an Angular 6 / 7 app by hiding/obfuscating the code通过隐藏/混淆代码来保护 Angular 6 / 7 应用程序
【发布时间】:2019-04-05 05:45:50
【问题描述】:

有没有办法混淆 Angular 6(或 7)应用程序的生产代码。生产代码是指在命令 ng build --prod 之后生成的 dist 文件夹。 我见过一个名为 Jscrambler 的软件,但它不是免费的。 我该怎么做?

谢谢

【问题讨论】:

标签: angular security angular6 obfuscation angular7


【解决方案1】:

如果你有 Angular 7+,你可以使用@angular-builders/custom-webpack 来使用javascript-obfuscator。请注意,我为 Angular 8+ 链接了 custom-webpack,假设您可能在一年前进行了升级。如果您需要 Angular 7 版本,他们在该页面上有指向 Angular 7 兼容版本 @angular-builders/custom-webpack 的链接

【讨论】:

    【解决方案2】:

    当您使用 Angular CLI 构建生产代码时,您的代码已经被缩小和丑化(由 UglifyJS),如 Angular doc 中所述

    The --prod meta-flag engages the following build optimization features.
    
     - Ahead-of-Time (AOT) Compilation: pre-compiles Angular component templates.
     - Production mode: deploys the production environment which enables production mode.
     - Bundling: concatenates your many application and library files into a few bundles.
     - Minification: removes excess whitespace, comments, and optional tokens.
     - Uglification: rewrites code to use short, cryptic variable and function names.
     - Dead code elimination: removes unreferenced modules and much unused code.
    

    如果您没有收到代码混淆,您可能需要检查您的 angular.json 文件并确保它包含以下设置:

    "configurations": {
      "production": {
        "optimization": true,
    

    【讨论】:

    • 为什么所有的仇恨?为什么没有参数的负-3? @Neo 所说的似乎是正确的。
    猜你喜欢
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    相关资源
    最近更新 更多