Command-line tool allows you to encrypt and compress HTML files for secure client-side deployment. It uses AES-128-CBC for encryption and ZIP for compression, generating the necessary Base64 variables for subsequent decryption and injection in the browser using libraries like CryptoJS and zip.js.
- Features
- How It Works
- Requirements
- Installation
- Usage
- Template Injectors
- Contributing
- License
- Contact
NOT YOUR TEMPLATE follows a three-step process to protect your HTML templates:
- HTML Reading: The application reads the content of your specified HTML file.
- AES-CBC Encryption:
- It generates a random 128-bit (16-byte) encryption key and a random 128-bit initialization vector (IV).
- The HTML content is then encrypted using AES in CBC (Cipher Block Chaining) mode.
- ZIP Compression:
- The encrypted content is compressed into a ZIP archive. This is useful for reducing the final data size and, consequently, the payload for the client.
- Base64 Encoding:
- The encrypted ZIP content, the key, and the IV are then encoded into Base64 format.
- These Base64 strings are what the application outputs, ready to be pasted into your client-side JavaScript code.
On the Client-Side (Browser):
The generated Base64 variables (encryptedBase64, keyBase64, ivBase64) are used in an injector (like the provided example) which will:
- Decode the
encryptedBase64string from Base64 back into aUint8Array. - Decompress the
Uint8Arrayusing thezip.jslibrary. - Decrypt the decompressed content using the key (
keyBase64) and IV (ivBase64) with theCryptoJSlibrary (AES-CBC). - The decrypted HTML content is then dynamically injected into your web page's DOM.
- Node.js: Version 16.x or higher.
- npm or yarn: A package manager.
- Clone and install deps:
git clone https://github.com/jomoza/NOTYOURTEMPLATE cd NOTYOURTEMPLATE npm install # or if you use yarn # yarn install
-t,--template <file.html>: (Required) Path to the HTML file to be encrypted and compressed.-o,--output <file.js>: (Optional) Path to the file where the generated variables will be saved. If not specified, the result will be printed to the console or copied to the clipboard.-c,--clipboard: (Optional) Copy the generated variables directly to the system clipboard.
- Encrypt
index.htmland print to console:node app.js --template index.html
- Encrypt
template.htmland save tovariables.js:node app.js --template template.html --output variables.js
- Encrypt
page.htmland copy to clipboard:node app.js --template page.html --clipboard
Once you've generated the Base64 variables, you'll need a client-side "injector" to decrypt and display the content. In the TEMPLATES folder of this repository, you'll find examples of HTML/JavaScript injectors you can adapt to your needs.
A basic example of how the HTML/JavaScript injector uses the generated variables is allowed at templates forlder
- Run
NOT YOUR TEMPLATEto generate theencryptedBase64,keyBase64, andivBase64variables. - Copy and paste these values into the HTML injector (replacing the `` comments).
- Ensure that the
crypto-jsandzip.jslibraries are correctly linked in your HTML (you can use the CDNs provided in the example). - Deploy this HTML file as you would any other web page. The encrypted content will be dynamically loaded and decrypted in the user's browser.
- Author: @j0moz4
- GitHub: https://github.com/j0moz4