codeenigma


Namecodeenigma JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryA lightweight, open-source tool for Python code obfuscation. CodeEnigma helps protect your logic from reverse engineering and unauthorized access, making it a practical alternative to PyArmor for securely distributing your Python applications
upload_time2025-07-27 10:23:31
maintainerNone
docs_urlNone
authorKrishnan S G
requires_python<3.14,>=3.10
licenseMIT
keywords obfuscation code protection python security pyarmor alternative secure distribution
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Image](https://raw.githubusercontent.com/KrishnanSG/codeenigma/main/static/logo.svg)

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI](https://img.shields.io/pypi/v/codeenigma)](https://pypi.org/project/codeenigma/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![CodeFactor](https://www.codefactor.io/repository/github/krishnansg/codeenigma/badge)](https://www.codefactor.io/repository/github/krishnansg/codeenigma)
[![Downloads](https://static.pepy.tech/badge/codeenigma)](https://pepy.tech/project/codeenigma)
[![CI](https://github.com/KrishnanSG/codeenigma/actions/workflows/main.yml/badge.svg)](https://github.com/KrishnanSG/codeenigma/actions)
[![Coverage](https://raw.githubusercontent.com/KrishnanSG/codeenigma/python-coverage-comment-action-data/badge.svg)](https://github.com/KrishnanSG/codeenigma/actions/workflows/python-coverage-comment-action-data.yml)

A lightweight, open-source tool for Python code obfuscation. CodeEnigma helps protect your logic from reverse engineering and unauthorized access, making it secure to distribute your Python applications.

## 🔒 Why CodeEnigma?
After searching extensively for a free and open-source Python obfuscation tool, I realized that most available options were either paid, closed-source, or opaque in how they worked. I wasn't comfortable letting a black-box tool obfuscate my production code without knowing exactly what it was doing — especially when it had access to sensitive logic.

So I built **CodeEnigma** — a transparent, self-contained solution that gives you full control over the obfuscation process, with no hidden logic and no external servers involved. 

This project is inspired by [PyArmor](https://pyarmor.dashingsoft.com/) but with a different approach.

## High Level Architecture

![Image](https://raw.githubusercontent.com/KrishnanSG/codeenigma/main/static/CodeEnigma.HLD.svg)

The working principle of CodeEnigma is simple:
1. The user provides the path to the Python module to obfuscate.
2. CodeEnigma reads the module's source code.
3. An AES-256 key is generated using a secure random number generator and set in `private.py`
4. Obfuscation runs file by file running the following steps:
   * 4.1. Compile using `compile(code, str(file_path), "exec")` 
   * 4.2. Compress the byte code using `zlib.compress(compiled_code)`
   * 4.3. Encode the compressed byte code using `base64.b64encode(compressed_code)`
   * 4.4. Encrypt the encoded byte code using `AESGCM(SECRET_KEY).encrypt(NONCE, obfuscated, associated_data=None)`
   _[refer for more details](codeenigma/core.py)_:
5. CodeEnigma creates a new module with the obfuscated code.
6. A codeenigma_runtime.pyx file is created with the deobfuscation logic to decrypt and execute the obfuscated code.
7. The runtime is compiled to a Python extension module using Cython. Also generates a codeenigma_runtime.whl file for distribution.
8. End of process, the obfuscated module is ready to be distributed as wheel files.

## Features

- 🔒 Strong encryption using AES-256
- 🔄 Simple API for obfuscating any python module
- 🔑 Secure and dynamic key generation
- 🛠️ Command-line interface for easy integration into build processes
- 📦 Lightweight and dependency-minimal

## Installation

Using Poetry:

```bash
poetry add codeenigma
```

Using pip:

```bash
pip install codeenigma
```

## Usage

CodeEnigma comes with a user-friendly command-line interface powered by Typer. The CLI provides helpful prompts and rich output.

### Basic Usage

To obfuscate a Python module:

```bash
codeenigma obfuscate /path/to/your/module
```

### Command Line Options

- `--expiration`, `-e`: Set an expiration date for the obfuscated code (YYYY-MM-DD)
- `--output`, `-o`, `--dist`: Specify output directory (default: 'dist')
- `--verbose`, `-v`: Show detailed output

#### Examples

Obfuscate with an expiration date:

> _The following example will obfuscate the module and set the expiration date to December 31, 2025, at 23:59:59+0530 (IST)._
```bash
codeenigma obfuscate /path/to/your/module -e "2025-12-31 23:59:59+0530"
```

Specify custom output directory:
```bash
codeenigma obfuscate /path/to/your/module -o custom_output
```

### Version Information

To check the installed version:
```bash
codeenigma version
```

## Contributing

Contributions are welcome! This is a complete free and open-source project. If you have any suggestions or find any bugs, please open an [issue](https://github.com/KrishnanSG/CodeEnigma/issues/new).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Built with ❤️ using Python
- Uses [cryptography](https://cryptography.io/) for secure encryption
- Uses [Cython](https://cython.org/) for compiling the runtime
- Logo Credits, Claude 🫡
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "codeenigma",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.10",
    "maintainer_email": null,
    "keywords": "obfuscation, code protection, python security, pyarmor alternative, secure distribution",
    "author": "Krishnan S G",
    "author_email": "krishsg525@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a1/bb/99b654011cb4adc79451406a8e0d89d95809f7e033e224ff5a1685e33043/codeenigma-1.2.0.tar.gz",
    "platform": null,
    "description": "![Image](https://raw.githubusercontent.com/KrishnanSG/codeenigma/main/static/logo.svg)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PyPI](https://img.shields.io/pypi/v/codeenigma)](https://pypi.org/project/codeenigma/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![CodeFactor](https://www.codefactor.io/repository/github/krishnansg/codeenigma/badge)](https://www.codefactor.io/repository/github/krishnansg/codeenigma)\n[![Downloads](https://static.pepy.tech/badge/codeenigma)](https://pepy.tech/project/codeenigma)\n[![CI](https://github.com/KrishnanSG/codeenigma/actions/workflows/main.yml/badge.svg)](https://github.com/KrishnanSG/codeenigma/actions)\n[![Coverage](https://raw.githubusercontent.com/KrishnanSG/codeenigma/python-coverage-comment-action-data/badge.svg)](https://github.com/KrishnanSG/codeenigma/actions/workflows/python-coverage-comment-action-data.yml)\n\nA lightweight, open-source tool for Python code obfuscation. CodeEnigma helps protect your logic from reverse engineering and unauthorized access, making it secure to distribute your Python applications.\n\n## \ud83d\udd12 Why CodeEnigma?\nAfter searching extensively for a free and open-source Python obfuscation tool, I realized that most available options were either paid, closed-source, or opaque in how they worked. I wasn't comfortable letting a black-box tool obfuscate my production code without knowing exactly what it was doing \u2014 especially when it had access to sensitive logic.\n\nSo I built **CodeEnigma** \u2014 a transparent, self-contained solution that gives you full control over the obfuscation process, with no hidden logic and no external servers involved. \n\nThis project is inspired by [PyArmor](https://pyarmor.dashingsoft.com/) but with a different approach.\n\n## High Level Architecture\n\n![Image](https://raw.githubusercontent.com/KrishnanSG/codeenigma/main/static/CodeEnigma.HLD.svg)\n\nThe working principle of CodeEnigma is simple:\n1. The user provides the path to the Python module to obfuscate.\n2. CodeEnigma reads the module's source code.\n3. An AES-256 key is generated using a secure random number generator and set in `private.py`\n4. Obfuscation runs file by file running the following steps:\n   * 4.1. Compile using `compile(code, str(file_path), \"exec\")` \n   * 4.2. Compress the byte code using `zlib.compress(compiled_code)`\n   * 4.3. Encode the compressed byte code using `base64.b64encode(compressed_code)`\n   * 4.4. Encrypt the encoded byte code using `AESGCM(SECRET_KEY).encrypt(NONCE, obfuscated, associated_data=None)`\n   _[refer for more details](codeenigma/core.py)_:\n5. CodeEnigma creates a new module with the obfuscated code.\n6. A codeenigma_runtime.pyx file is created with the deobfuscation logic to decrypt and execute the obfuscated code.\n7. The runtime is compiled to a Python extension module using Cython. Also generates a codeenigma_runtime.whl file for distribution.\n8. End of process, the obfuscated module is ready to be distributed as wheel files.\n\n## Features\n\n- \ud83d\udd12 Strong encryption using AES-256\n- \ud83d\udd04 Simple API for obfuscating any python module\n- \ud83d\udd11 Secure and dynamic key generation\n- \ud83d\udee0\ufe0f Command-line interface for easy integration into build processes\n- \ud83d\udce6 Lightweight and dependency-minimal\n\n## Installation\n\nUsing Poetry:\n\n```bash\npoetry add codeenigma\n```\n\nUsing pip:\n\n```bash\npip install codeenigma\n```\n\n## Usage\n\nCodeEnigma comes with a user-friendly command-line interface powered by Typer. The CLI provides helpful prompts and rich output.\n\n### Basic Usage\n\nTo obfuscate a Python module:\n\n```bash\ncodeenigma obfuscate /path/to/your/module\n```\n\n### Command Line Options\n\n- `--expiration`, `-e`: Set an expiration date for the obfuscated code (YYYY-MM-DD)\n- `--output`, `-o`, `--dist`: Specify output directory (default: 'dist')\n- `--verbose`, `-v`: Show detailed output\n\n#### Examples\n\nObfuscate with an expiration date:\n\n> _The following example will obfuscate the module and set the expiration date to December 31, 2025, at 23:59:59+0530 (IST)._\n```bash\ncodeenigma obfuscate /path/to/your/module -e \"2025-12-31 23:59:59+0530\"\n```\n\nSpecify custom output directory:\n```bash\ncodeenigma obfuscate /path/to/your/module -o custom_output\n```\n\n### Version Information\n\nTo check the installed version:\n```bash\ncodeenigma version\n```\n\n## Contributing\n\nContributions are welcome! This is a complete free and open-source project. If you have any suggestions or find any bugs, please open an [issue](https://github.com/KrishnanSG/CodeEnigma/issues/new).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Built with \u2764\ufe0f using Python\n- Uses [cryptography](https://cryptography.io/) for secure encryption\n- Uses [Cython](https://cython.org/) for compiling the runtime\n- Logo Credits, Claude \ud83e\udee1",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A lightweight, open-source tool for Python code obfuscation. CodeEnigma helps protect your logic from reverse engineering and unauthorized access, making it a practical alternative to PyArmor for securely distributing your Python applications",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/KrishnanSG/codeenigma",
        "Source": "https://github.com/KrishnanSG/codeenigma",
        "Tracker": "https://github.com/KrishnanSG/codeenigma/issues"
    },
    "split_keywords": [
        "obfuscation",
        " code protection",
        " python security",
        " pyarmor alternative",
        " secure distribution"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4baa21efbdd582b37b484a2b14e33a39a10a0dd3e4440a14d630ae52db27a64",
                "md5": "50d456ab93002f02a5ac8e41daa8af32",
                "sha256": "80fd07d53e3c7966e7f6b4b4b6e5eab1152840f3c66406aabdd0072c17022dfc"
            },
            "downloads": -1,
            "filename": "codeenigma-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "50d456ab93002f02a5ac8e41daa8af32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10",
            "size": 21730,
            "upload_time": "2025-07-27T10:23:28",
            "upload_time_iso_8601": "2025-07-27T10:23:28.682720Z",
            "url": "https://files.pythonhosted.org/packages/b4/ba/a21efbdd582b37b484a2b14e33a39a10a0dd3e4440a14d630ae52db27a64/codeenigma-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1bb99b654011cb4adc79451406a8e0d89d95809f7e033e224ff5a1685e33043",
                "md5": "c1021a6cca756d9830a11296fbe96a22",
                "sha256": "a35c705291567c0d30745f24f71524944e90091ef7f80f3dbf656f366fda74df"
            },
            "downloads": -1,
            "filename": "codeenigma-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c1021a6cca756d9830a11296fbe96a22",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.10",
            "size": 14982,
            "upload_time": "2025-07-27T10:23:31",
            "upload_time_iso_8601": "2025-07-27T10:23:31.403209Z",
            "url": "https://files.pythonhosted.org/packages/a1/bb/99b654011cb4adc79451406a8e0d89d95809f7e033e224ff5a1685e33043/codeenigma-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-27 10:23:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KrishnanSG",
    "github_project": "codeenigma",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "codeenigma"
}
        
Elapsed time: 1.18335s