electron-builder-encryptor ![npm](https://img.shields.io/npm/v/electron-builder-encryptor.svg)
![ci](https://github.com/dusionlike/electron-builder-encryptor/actions/workflows/ci.yml/badge.svg)
English | 简体中文
simple electron package encryption tool
Examples
Features
- 🐵 Very easy to use, just add a few lines of code
- 💚 Framework agnostic, easy to add to your existing projects
- 🤷♂️ It only takes effect when packaging with
electron-builder
, and does not affect development and debugging - 🔒 Use bytenode to encrypt the main process and custom method to encrypt the renderer process
- 👀 Prevent tampering with the
app.asar
file
Usage
npm i electron-builder-encryptor -D
npm i adm-zip bytenode mime original-fs yaml
Add afterPack
to electron-builder
configuration
// package.json
{
"build": {
"asar": true,
"afterPack": "node_modules/electron-builder-encryptor"
}
}
or
// electron-builder.json
{
"asar": true,
"afterPack": "node_modules/electron-builder-encryptor"
}
in mian process
if (!app.isPackaged) {
mainWindow.loadFile('renderer/index.html')
} else {
mainWindow.loadURL('myclient://apps/index.html')
}
Note: The renderer process that needs to be encrypted must be placed in the renderer
folder under the directory where the entry file main.js
is located
Configuration
import { defineConfig } from 'electron-builder-encryptor'
export default defineConfig({
key: 'xxx000777',
})
all configuration
export declare interface UserConfig {
key?: string
protocol?: string
privileges?: Privileges
preload?: string | string[]
renderer?: {
entry: string
output: string
}
syncValidationChanges?: boolean
autoRunRenderer?: boolean
}
Migrating from v0.x
In order to update renderer
and mian
separately, 1.x separates the encrypted renderer.pkg by default. If you need to restore the behavior of 0.x, you can set renderer.output
to ''
export default defineConfig({
renderer: {
entry: 'renderer',
output: ''
}
})
When package.json
exists in the renderer
folder, the renderer.yml
file will be generated in the packaged renderer.pkg
directory
License
MIT License