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:
"build": {
......
"asar": true,
"files": [
"**/*",
"!frontend/", // Filter front-end source code
"!run/",
"!logs/",
"!data/",
"!electron/" // Filter the electronic folder; If encryption is not used, the folder cannot be filtered
],
......
}
config file
requirements:ee-core >= 1.3.2
file ./electron/config/encrypt.js
module.exports = {
type: 'bytecode', // bytecode | confusion
directory: [ // Directory to be encrypted
'electron'
],
fileExt: ['.js'], // The file suffix that needs to be encrypted only supports js temporarily
};
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
"scripts": {
......
"encrypt": "ee-core encrypt --type=bytecode",
......
}
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
# add toString() , returns a string representation of a class
ExampleController.toString = () => '[class ExampleController]';
# Export module
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.