Skip to content

jomoza/NOTYOURTEMPLATE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTYOURTEMPLATE

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.


📖 Table of Contents


NOT YOUR TEMPLATE follows a three-step process to protect your HTML templates:

  1. HTML Reading: The application reads the content of your specified HTML file.
  2. 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.
  3. 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.
  4. 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:

  1. Decode the encryptedBase64 string from Base64 back into a Uint8Array.
  2. Decompress the Uint8Array using the zip.js library.
  3. Decrypt the decompressed content using the key (keyBase64) and IV (ivBase64) with the CryptoJS library (AES-CBC).
  4. The decrypted HTML content is then dynamically injected into your web page's DOM.

🚀 Requirements

  • Node.js: Version 16.x or higher.
  • npm or yarn: A package manager.

⚙️ Installation

  1. Clone and install deps:
    git clone https://github.com/jomoza/NOTYOURTEMPLATE
    cd NOTYOURTEMPLATE
    npm install
    # or if you use yarn
    # yarn install

💻 Usage

Command-Line Options

  • -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.

Usage Examples

  1. Encrypt index.html and print to console:
    node app.js --template index.html
  2. Encrypt template.html and save to variables.js:
    node app.js --template template.html --output variables.js
  3. Encrypt page.html and copy to clipboard:
    node app.js --template page.html --clipboard

📥 Template Injectors

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.

Injector Example

A basic example of how the HTML/JavaScript injector uses the generated variables is allowed at templates forlder

Using the Injector

  1. Run NOT YOUR TEMPLATE to generate the encryptedBase64, keyBase64, and ivBase64 variables.
  2. Copy and paste these values into the HTML injector (replacing the `` comments).
  3. Ensure that the crypto-js and zip.js libraries are correctly linked in your HTML (you can use the CDNs provided in the example).
  4. 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.