requirements:ee-core >= 1.2.10

currently, the framework supports two types of code encryption: bytecode encryption and compression obfuscation encryption. Of course, you can also confuse encryption before bytecode encryption.

Filter source code when packaging

note: encryption is not used , do not filter.
Open the package.json file and modify it build.files array properties, add “! electron/“, as follows:

  1. "build": {
  2. ......
  3. "asar": true,
  4. "files": [
  5. "**/*",
  6. "!frontend/", // Filter front-end source code
  7. "!run/",
  8. "!logs/",
  9. "!data/",
  10. "!electron/" // Filter the electronic folder; If encryption is not used, the folder cannot be filtered
  11. ],
  12. ......
  13. }

config file

requirements:ee-core >= 1.3.2

file ./electron/config/encrypt.js

  1. module.exports = {
  2. type: 'bytecode', // bytecode | confusion
  3. directory: [ // Directory to be encrypted
  4. 'electron'
  5. ],
  6. fileExt: ['.js'], // The file suffix that needs to be encrypted only supports js temporarily
  7. };

type

  • bytecode
  • confusion

modify the encryption type

Recommended upgrade ee-core, use the above configuration file

open the package.json file and modify it scripts.encrypt script properties, as follows:
parameter: — type =

  • bytecode
  • confusion
    1. "scripts": {
    2. ......
    3. "encrypt": "ee-core encrypt --type=bytecode",
    4. ......
    5. }

    Encrypted file location

    after encryption, the file ./public/electron note that the file import path is included in the business code.

Note: The dev environment (or prod environment without encryption) uses the ‘./electron/‘ code, and the prod environment uses the ‘./public/electron/‘ code.

Method 1: bytecode encryption

What is bytecode encryption?
Bytecode is an intermediate representation after source code compilation. It is similar to assembly and is an instruction executed by a virtual machine. Reverse Compilation is almost as difficult as traditional compilation languages.

Code requirements:

the toString() method is required to be added to the controller and service code at the service layer to identify the encrypted. jsc (class) module. For example: ExampleController controller

  1. # add toString() , returns a string representation of a class
  2. ExampleController.toString = () => '[class ExampleController]';
  3. # Export module
  4. module.exports = ExampleController;

build requirements:

  • if cross build if an error is reported when the software is running, build it on the corresponding platform. The operation is as follows:
  • build on windows-32-bit operating system: npm run build-w (32-bit)
  • build on windows-64-bit operating system: npm run build-w (64-bit)
  • build on MacOS-amd operating system:npm run build-m
  • build on MacOS-arm operating system:npm run build-m-arm64 (m1)
  • there are many distribution versions on Linux. Please test them yourself.

    Method 2: compression obfuscation encryption

    compression confusion mainly compresses the code into one line, and simplifies and replaces variables and function names in the code according to certain rules.

Code requirements: None

Build requirements:

  • you can build 32-bit and 64-bit applications on windows-64-bit operating systems at the same time.
  • others are as above.