vue3 项目加密【踩坑无数】-更新

4,322 阅读1分钟

作者相关文章: vue2项目加密混淆

采用技术:vite4.1 + vue3

步骤一

npm i rollup-obfuscator

步骤二

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { obfuscator } from "rollup-obfuscator";
// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  alias: {
    "@": path.resolve(__dirname, "./src"),
  },
  plugins: [
    vue(),
  ],
  build: {
    rollupOptions: {
      plugins: [
        obfuscator({
          compact: true,
          controlFlowFlattening: true,
          controlFlowFlatteningThreshold: 1,
          deadCodeInjection: true,
          deadCodeInjectionThreshold: 1,
          debugProtection: true,
          debugProtectionInterval: 0,
          disableConsoleOutput: true,
          identifierNamesGenerator: "hexadecimal",
          log: false,
          renameGlobals: false,
          rotateStringArray: true,
          selfDefending: true,
          shuffleStringArray: true,
          splitStrings: true,
          splitStringsChunkLength: 10,
          stringArray: true,
          stringArrayEncoding: ["rc4"],
          stringArrayThreshold: 1,
          transformObjectKeys: true,
          unicodeEscapeSequence: false,
        }),
      ],
    },
  },
});

使用无效插件:🚧

  1. vite-mahlzeit-obfuscator
  2. vite-plugin-javascript-obfuscator
  3. rollup-plugin-javascript-obfuscator
  4. vite-plugin-obfuscator

感慨😢

这些使用无效插件按照官方文档方式尝试了遍各种报错,可能是作者本人操作有问题,大家也可以再试试

注意

该插件配合ts + vue 下还是会有些问题,部分页面生成失败,有的页面无法打开,还是

-------------------2023-09-07-----------------

更新-插件调用

再次测试了加密插件

  1. rollup-plugin-javascript-obfuscator 还是采用的javascript-obfuscator@0.x版本,使用后没啥作用
  2. rollup-obfuscator 兼容性还是存在问题,打包会存在编译失败

感慨:vite 加密混淆,还需努力