mojic

Obfuscate C source code into e...
Log | Files | Refs | README | LICENSE

README.md (5756B)


      1 > [!IMPORTANT]
      2 > ## Notice: Project Discontinuation & Local Patch (v2.1.5)
      3 > I apologize for the inconvenience, but Mojic is being discontinued. This release (v2.1.5) marks the final patch to the GitHub repository.
      4 >
      5 > I have forgotten my npm account password, and during a recent migration to Linux, my recovery passcode file was also lost, completely locking me out of the account. Because of this, I am unable to publish a patch to fix a broken dependency (@notamitgamer/mojic) that is currently causing npm install commands from the registry to fail with a 404 error.
      6 > 
      7 > If you still wish to use the tool, you can clone this repository and run or install it locally:
      8 > ```bash
      9 > # Clone and navigate to the directory
     10 > git clone https://github.com/notamitgamer/mojic.git
     11 > cd mojic
     12 > 
     13 > # Install dependencies and link it globally to use the 'mojic' command
     14 > npm install
     15 > npm link
     16 
     17 # Mojic v2.1.5
     18 
     19 ![NPM Downloads](https://img.shields.io/npm/d18m/mojic)
     20 
     21 > **Operation Ironclad: Obfuscate C source code into a randomized, password-seeded stream of emojis.**
     22 
     23 **Mojic** (Magic + Emoji + Logic) is a sophisticated CLI tool designed to transform readable C code into an unrecognizable chaotic stream of emojis. Unlike simple substitution ciphers, Mojic uses your password to seed a cryptographically strong Pseudo-Random Number Generator (PRNG), creating a unique "Emoji Universe" and rolling cipher for every single session.
     24 
     25 ## Key Features
     26 
     27 * **AES-256-CTR PRNG:** Uses a military-grade cryptographically secure pseudorandom number generator (seeded via Scrypt) to handle shuffling and polymorphism.
     28 * **Polymorphic Keywords:** Common C keywords (`int`, `void`, `return`) are mapped to emojis that *change* every time they appear based on the PRNG state. Frequency analysis is impossible.
     29 * **XOR Whitening:** Before encoding, all raw data (whitespace, variable names) is XORed with the AES keystream. This ensures that repeating patterns—like 4 spaces of indentation—never produce the same emoji sequence twice.
     30 * **Base-1024 Compression:** Non-keyword code is compressed using a custom Base-1024 scheme (5 bytes → 4 emojis), keeping file size manageable.
     31 * **Integrity Sealed:** Every file ends with an HMAC-SHA256 signature. Any tampering with the emoji stream results in an immediate `FILE_TAMPERED` error.
     32 * **Moon Header Protocol:** Metadata (Salt + Auth Check) is encoded using a specific alphabet of Moon and Clock phases (`🌑🌒🕐`), allowing instant password verification before decryption starts.
     33 * **Stream Architecture:** Built on Node.js `Transform` streams to handle large files efficiently with minimal memory footprint.
     34 
     35 ## Installation
     36 
     37 Since Mojic is available on npm, you can install it globally with a single command:
     38 
     39 ```bash
     40 npm install -g mojic
     41 ```
     42 
     43 Or run it directly using `npx` without installing:
     44 
     45 ```bash
     46 npx mojic encode main.c
     47 ```
     48 
     49 ## Usage
     50 
     51 ### 1. Encrypting Code (`encode`)
     52 Transforms a `.c` file into a `.mojic` file.
     53 
     54 ```bash
     55 # Encrypt a single file
     56 mojic encode main.c
     57 
     58 # Encrypt an entire directory recursively
     59 mojic encode ./src -r
     60 
     61 # Flatten/Minify code structure before encryption (Removes newlines/indentation)
     62 mojic encode main.c --flat
     63 ```
     64 *You will be prompted to create a password. This password is required to decrypt.*
     65 
     66 ### 2. Decrypting Code (`decode`)
     67 Restores the original C code from a `.mojic` file.
     68 
     69 ```bash
     70 # Decrypt a single file
     71 mojic decode main.mojic
     72 
     73 # Decrypt an entire directory recursively
     74 mojic decode ./src -r
     75 ```
     76 
     77 ### 3. Security & Rotation Tools (`srt`)
     78 Manage encrypted files without ever revealing their plaintext contents.
     79 
     80 ```bash
     81 # Rotate Password: Changes the password of an encrypted file
     82 mojic srt --pass secret.mojic
     83 
     84 # Re-Encrypt: Re-shuffles the entropy (New Salt) with the SAME password
     85 # (Useful to change the visual emoji pattern without changing the password)
     86 mojic srt --re secret.mojic
     87 ```
     88 
     89 ## Under the Hood (Algorithm)
     90 
     91 Mojic v2.1.0 implements a custom crypto-system dubbed **"Operation Ironclad"**.
     92 
     93 1.  **Derivation Phase:**
     94     * **Input:** User Password + 32-byte Random Salt.
     95     * **KDF:** `Scrypt` (N=16384, r=8, p=1).
     96     * **Output:** 80 bytes (32 bytes AES Key, 16 bytes AES IV, 32 bytes HMAC Auth Key).
     97 
     98 2.  **The Emoji Universe:**
     99     * The engine generates a universe of ~1,100 valid unicode characters (Emoticons, Transport, Symbols).
    100     * This universe is **shuffled** using the `AES-256-CTR` CSPRNG initialized with the derived key.
    101 
    102 3.  **Polymorphic Encryption:**
    103     * **C Keywords:** The engine detects C keywords (e.g., `while`). It assigns them a "Base Emoji" from the shuffled universe.
    104     * **The Twist:** It doesn't just print the Base Emoji. It calculates a random offset using the PRNG to pick a *different* emoji that maps back to the keyword. This means `int` might look like `🚀` on line 1 and `🌮` on line 5.
    105 
    106 4.  **XOR Whitening:**
    107     * Before encoding non-keyword data (variable names, strings, whitespace), the engine generates a random mask from the AES stream.
    108     * The raw data is **XORed** with this mask. This hides repetitive patterns (like indentation or common variable names) effectively turning them into white noise before they are converted to emojis.
    109 
    110 5.  **Base-1024 Encoding:**
    111     * The whitened data is buffered into 5-byte chunks.
    112     * These chunks are treated as a single large integer and converted into 4 base-1024 digits (mapped to emojis).
    113 
    114 6.  **The Header:**
    115     * The Salt and a 4-byte Auth Check are written to the file header using the **Moon/Clock Alphabet** (`🌑🌒🌓🌔...`).
    116     * **Benefit:** This allows `mojic` to tell you "Incorrect Password" instantly, rather than churning out garbage data first.
    117 
    118 ## License
    119 
    120 This project is licensed under the Apache License 2.0.
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror