Skip to main content

Encodify - Python Code Encoding Module

Python Version

encodify is a powerful Python module designed to provide a suite of advanced encoding techniques for Python scripts. These encoding methods encompass compression, base64 encoding, and XOR encryption, allowing users to obfuscate code for enhanced security or distribution.

Table of Contents

Installation

To integrate encodify into your project, you can use pip:

pip install encodify

Usage

Importing the Module

To employ the functionalities of encodify, import the Encodify class from the module:

from encodify import Encodify

Creating an Encoder Instance

Instantiate the Encodify class to access a wide array of encoding techniques:

encoder = Encodify()

Encoding Specific Code

encodify excels at encoding specific Python code snippets. For instance, utilizing the m1 encoding method:

code_to_encode = "print('Hello, World!')"
encoded_code = encoder.m1(code_to_encode)

Generating Random Payload

For a dynamically selected encoding method, use the random_payload method. It produces a randomized payload, increasing the level of code obfuscation:

random_payload = encoder.random_payload("print('Hello, World!')", 2)

Generating Payload with a Specific Encoding Method

Tailor the encoding method to your requirements with the gen_payload method. Specify the method number to achieve the desired encoding:

# Choose the encoding method (e.g., m2)
chosen_encoding_method = 2
payload = encoder.gen_payload(chosen_encoding_method, "print('Hello, World!')")

Additional Customization

encodify offers extensive customization options. These include string replacements and appending/prepending custom code to the encoded output, allowing for fine-tuned control over the obfuscation process.

Args for gen_payload Function

The gen_payload function accepts the following arguments:

  • choice (int): The chosen encoding technique, determining the applied encoding method. Refer to the module documentation for a complete list of available choices.

  • data (str): The Python code to be encoded.

  • line (int, optional): The number of lines for line-based encoding (default is 2). This argument is applicable for specific encoding methods.

  • options (dict, optional): Further customization options (default is None). This may encompass string replacements or the addition of custom code.

Available Encoding Methods

+------+---------------------------------------------------+
|  No  |           Encoding Method Description            |
+------+---------------------------------------------------+
|  1   |              m1: Gzip + Marshal + Base64          |
|  2   |          m2: LZMA + Base64 + Marshal              |
|  3   |         m3: LZMA + Base85 + Marshal               |
|  4   |              m4: LZMA + Marshal                   |
|  5   |          m5: Base64 + LZMA + Marshal              |
|  6   |       m6: LZMA + Zlib + Marshal + Base64         |
|  7   |     m7: LZMA + Gzip + Marshal + Base64           |
|  8   |              m8: LZMA + Marshal                   |
|  9   |       m9: Base64 + Gzip + Marshal + Base64        |
|  10  |      m10: Base64 + Gzip + Marshal + LZMA          |
|  11  |     m11: Base64 + Gzip + Marshal + Base64         |
|  20  |     m20: Minify + Base64 + Gzip + Marshal         |
|  23  |      l1: Line-based Encoding with Base85          |
|  24  |  l2: Line-based Encoding with Base85 + LZMA       |
|  25  |  l25: Line-based Encoding with Base64 + LZMA      |
|  26  | l26: Line-based Encoding with Base64 + Codecs     |
|  27  |  l27: Line-based Encoding with XOR Encryption     |
|  28  | l28: Line-based Encoding with Base64 + XOR        |
|  29  | l29: Line-based Encoding with Base64 + XOR        |
|  30  | l30: Line-based Encoding with XOR + Codecs        |
+------+---------------------------------------------------+

Advanced Techniques

encodify offers an array of advanced encoding techniques. These include line-based encoding, various combinations of compression, and XOR encryption. For in-depth guidance on these techniques, refer to the module's extensive documentation.

Examples

Explore some advanced examples showcasing the versatility of encodify:

from encodify import Encodify

# Create an instance of Encodify
encoder = Encodify()

# Example 1: Encoding with m2 method
code_to_encode = "for i in range(5):\n    print(f'Number: {i}')"
encoded_code_m2 = encoder.m2(code_to_encode)

# Example 2: Encoding with l1 method
line_based_code = "print('Hello, World!')"
encoded_line_based_code = encoder.l1(line_based_code, 3)

# Example 3: Generating a random payload
random_payload = encoder.random_payload("print('Hello, World!')", 2)

# Example 4: Generating a payload with a specific encoding method (m11)
chosen_encoding_method = 11
payload_m11 = encoder.gen_payload(chosen_encoding_method, "print('Hello, World!')")

# Example 5: Customizing output with options
options = {
    "replace_strings": {"print": "display"},
    "prepend_code": "import datetime\n",
    "append_code": "\nprint(f'Execution Time: {datetime.datetime.now()}')"
}
customized_payload = encoder.gen_payload(1, "print('Hello, World!')", options=options)

Best Practices and Considerations

  1. Use Responsibly: This module is primarily intended for educational purposes. Use it responsibly and within the boundaries of applicable laws and ethical guidelines.

  2. Testing and Verification: Always test the encoded code to ensure it functions as expected.

  3. Documentation: Document the encoding method used and keep a record for future reference.

Repository Views Views

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for encodify 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for encodify 1.0.4
File Size Uploaded Provenance Actions
encodify-1.0.4.tar.gz 6.8 kB Without provenance Details for encodify-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for encodify 1.0.4
File Interpreter ABI Platform Actions
encodify-1.0.4-py3-none-any.whl Python 3 none any Details for encodify-1.0.4-py3-none-any.whl

Total release size: 13.7 kB

Release files / encodify-1.0.4.tar.gz

Download URL encodify-1.0.4.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fb7e00bd28884e4bd504e1f9c2a2ac272b5f82c9f8355a9346579550e7b3a02e
BLAKE2b-256 checksum
How to use checksums
ec6503a5e314f0c797386ec310688d1c8ffd1caf5b74db7470b41dcf2dedb38c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / encodify-1.0.4-py3-none-any.whl

Download URL encodify-1.0.4-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72f737250cbefe11efa33bdd18b554366bbd85c85280bad3693fa09de861badc
BLAKE2b-256 checksum
How to use checksums
223076f7ef8bfd8dd896722fadbcb1496160777949027c0e8931578d5c2e4820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for encodify 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page