or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdconfiguration.mdindex.mdlicensing.mdobfuscation.mdplatform-support.mdproject-management.md
tile.json

tessl/pypi-pyarmor

A command-line tool for obfuscating Python scripts, binding obfuscated scripts to specific machines, and setting expiration dates

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyarmor@9.1.x

To install, run

npx @tessl/cli install tessl/pypi-pyarmor@9.1.0

index.mddocs/

PyArmor

A comprehensive Python script obfuscation tool that protects Python intellectual property through code obfuscation, hardware binding, and license management. PyArmor provides seamless replacement of original scripts with obfuscated versions while maintaining compatibility, offering multiple protection strategies from basic obfuscation to advanced machine-code compilation.

Package Information

  • Package Name: pyarmor
  • Language: Python
  • Installation: pip install pyarmor
  • License: Free To Use But Restricted (commercial licensing available)

Core Imports

import pyarmor

For programmatic access to legacy API:

from pyarmor import utils, project
from pyarmor.pyarmor import main_entry, main_entry_8

For modern CLI components (advanced usage):

from pyarmor.cli.context import Context
from pyarmor.cli.generate import Builder
from pyarmor.cli.register import Register, WebRegister
from pyarmor.cli.config import Configer

Basic Usage

Command Line Usage (Primary Interface)

# Install PyArmor
pip install pyarmor

# Basic script obfuscation
pyarmor gen foo.py

# Obfuscate with options
pyarmor gen --recursive --output dist --mix-str src/

# Advanced obfuscation with hardware binding
pyarmor gen --bind-device "00:11:22:33:44:55" --expired "2024-12-31" foo.py

# Pack with PyInstaller
pyarmor gen --pack onefile foo.py

# Check configuration
pyarmor cfg

# Register license
pyarmor reg pyarmor-regcode-xxxx.txt

Programmatic Usage (Advanced)

import os
from pyarmor import utils, project

# Initialize PyArmor environment
utils.pytransform_bootstrap()

# Create and configure project
proj = project.Project()
proj.name = "MyProject"
proj.src = "src"
proj.output = "dist"
proj.entry = "main.py"
proj.obf_code = 1  # Enable code obfuscation
proj.obf_mod = 1   # Enable module obfuscation
proj.save("myproject.json")

# Obfuscate scripts
capsule = utils.make_capsule(None)
utils.make_runtime(capsule, "dist")
utils.encrypt_script(capsule, "src/main.py", "dist/main.py")

Architecture

PyArmor employs a multi-layered protection architecture:

  • Script Layer: Python source code transformation and obfuscation
  • Module Layer: Import-time protection and validation
  • Runtime Layer: C extension libraries providing core protection
  • License Layer: Hardware binding and time-based restrictions
  • Platform Layer: Cross-platform support with native libraries

The tool supports multiple interface generations:

  • Legacy (v7): Full-featured interface with project management
  • Modern (v8+): Streamlined CLI with simplified commands
  • Hybrid (v9+): Combined interface supporting both approaches

Capabilities

Command Line Interface

Primary interface for PyArmor providing obfuscation, configuration, and license management through intuitive commands. Supports both modern streamlined interface and legacy full-featured commands.

# Modern CLI Commands (pyarmor, pyarmor-8)
def gen(*args, **kwargs): ...  # Generate obfuscated scripts
def cfg(*args, **kwargs): ...  # Configuration management  
def reg(*args, **kwargs): ...  # License registration
def man(*args, **kwargs): ...  # Interactive help system

# Legacy CLI Commands (pyarmor-7)  
def obfuscate(*args, **kwargs): ...  # Direct obfuscation without project
def init(*args, **kwargs): ...       # Initialize project
def build(*args, **kwargs): ...      # Build project
def config(*args, **kwargs): ...     # Configure project
def licenses(*args, **kwargs): ...   # Generate license files
def pack(*args, **kwargs): ...       # Package with external tools

Command Line Interface

Project Management

Create, configure, and manage PyArmor projects for organized obfuscation workflows with persistent settings and batch processing capabilities.

class Project(dict):
    def open(self, path: str) -> None: ...
    def save(self, path: str) -> None: ...
    def check(self) -> bool: ...
    def get_build_files(self, force: bool = False, excludes: list = []) -> list: ...
    def info(self) -> str: ...
    def _update(self, **kwargs) -> None: ...

Project Management

Script Obfuscation

Core obfuscation engine providing multiple protection levels from basic name mangling to advanced binary code compilation with machine instruction generation.

def encrypt_script(pubkey, filename: str, destname: str, wrap_mode: int = 1, obf_code: int = 1, obf_mod: int = 1, adv_mode: int = 0, rest_mode: int = 1, entry: int = 0, protection: int = 0, platforms = None, plugins = None, rpath = None, suffix: str = '', sppmode: bool = False, mixins = None) -> None: ...
def make_runtime(capsule, output: str, licfile = None, platforms = None, package: bool = False, suffix: str = '', supermode: bool = False) -> None: ...
def make_capsule(filename: str) -> None: ...
def make_entry(entris: str, path: str, output: str, rpath = None, relative = None, suffix: str = '', advanced: int = 0) -> None: ...
def make_bootstrap_script(output: str, **kwargs) -> None: ...

Script Obfuscation

License Management

Generate and manage licenses with hardware binding, expiration dates, and custom restrictions for controlling access to obfuscated scripts.

def make_license_key(capsule, code: str, output: str = None, key = None, legency: int = 0) -> None: ...
def query_keyinfo(key: str) -> dict: ...
def activate_regcode(ucode: str) -> dict: ...
def register_keyfile(filename: str, upgrade: bool = False, legency: bool = False) -> None: ...
def get_registration_code() -> str: ...

License Management

Configuration Management

System-wide and project-specific configuration with hierarchical settings and interactive configuration shell for managing obfuscation parameters.

class Configer:
    def list_sections(self, local: bool = True, name: str = None) -> list: ...
    def list_options(self, sect: str, local: bool = True, name: str = None) -> list: ...
    def run(self, options: list, local: bool, name: str) -> None: ...
    def reset(self, options: list, local: bool, name: str) -> None: ...

class Context:
    def __init__(self, *paths): ...
    def push(self, options: dict) -> None: ...
    def get_res_options(self, fullname: str, catalog: str) -> dict: ...

Configuration Management

Platform Support

Cross-platform obfuscation with automatic platform detection, library downloading, and support for 40+ target platforms including embedded systems.

def show_hd_info(name: str = None) -> str: ...
def download_pytransform(platname: str, **kwargs) -> None: ...
def check_cross_platform(platforms: list, **kwargs) -> None: ...
def get_platform_name() -> str: ...
def format_platform(system: str = None, machine: str = None) -> str: ...

Platform Support

Types

# Project Configuration
class ProjectConfig:
    name: str
    title: str  
    src: str
    output: str
    entry: str
    obf_code: int      # 0=disable, 1=enable, 2=advanced
    obf_mod: int       # 0=disable, 1=enable
    wrap_mode: int     # 0=disable, 1=enable
    advanced_mode: int # 0-5 protection levels
    restrict_mode: int # 0=none, 1=import, 2=private, 3=restrict
    runtime_path: str
    platform: str
    package_runtime: int
    cross_protection: int
    license_file: str

# Obfuscation Options  
class ObfuscationOptions:
    recursive: bool
    output: str
    obf_module: int
    obf_code: int
    mix_str: bool
    enable_bcc: bool
    enable_jit: bool
    enable_rft: bool
    enable_themida: bool
    assert_call: bool
    assert_import: bool
    restrict_module: int
    platforms: list
    outer: bool
    expired: str
    period: int
    devices: list
    bind_data: str

# Registration Info
class RegistrationInfo:
    product: str
    version: str
    lictype: str
    features: list
    expired: str
    devices: int
    platform: str