Metadata-Version: 2.4
Name: magiclock
Version: 0.5.6
Summary: MagicLock — software licensing & code protection (machine-fingerprint node-lock) + the unified `magiclock` CLI (runtime gate, Noise_NK channel, compiled-binary build tool).
License-Expression: LicenseRef-Proprietary
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=42
Provides-Extra: build
Requires-Dist: nuitka>=2; extra == "build"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Dynamic: license-file

# MagicLock — Python Source Code Encryption & AI Model Protection

**Encrypt Python source code and AI models — they run only on the devices you authorize, fully offline.**

[Website](https://magiclock.net) · [Documentation](https://magiclock.net/docs) · [Pricing](https://magiclock.net/pricing) · [GitHub](https://github.com/ruisv/magiclock)

**🌍 Languages:** [English](#magiclock--python-source-code-encryption--ai-model-protection) · [简体中文](#简体中文) · [繁體中文](#繁體中文) · [日本語](#日本語) · [한국어](#한국어) · [Français](#français)

![Python 3.9–3.14](https://img.shields.io/badge/python-3.9%E2%80%933.14-blue)
![Platforms](https://img.shields.io/badge/platforms-macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-lightgrey)
![Runtime network](https://img.shields.io/badge/runtime%20network-not%20required-success)
![Free trial](https://img.shields.io/badge/free%20trial-48h%2C%20no%20card-orange)
![6 languages](https://img.shields.io/badge/CLI%20%26%20portal-6%20languages-blueviolet)

MagicLock is a commercial tool for **Python source code protection**, **AI model encryption**, and **software licensing**. One command turns your `.py` files and model weights into encrypted artifacts that still import and run like ordinary Python — but only on machines you authorize. Verification and decryption happen **fully offline**: no dongle, no license server for you to run, no network calls at run time.

## Why MagicLock

- **One command, zero code changes.** `magiclock protect app.py` encrypts your source. No decorators, no annotations, no build-system surgery — every protected module passes the runtime gate before a single line executes.
- **AI models decrypt in memory, nowhere else.** Weights are encrypted once, then sealed per authorized device. They unlock only at the moment of inference — never written to disk in plaintext, and no decryption secret ever leaves the device (no server can hand it over, including MagicLock's).
- **The license is the machine.** Activate once online; from then on every run passes a five-step gate locally — authenticity, validity, device fingerprint, entitlement, freshness — with **zero network connections**.
- **Two protection tiers.** The convenience tier (`.pya` encrypted artifacts) needs no compiler. The compiled tier (`magiclock build`) weaves a license gate into **every module** and compiles to native machine code — no plaintext Python ships, and no single check to find and patch out.
- **Two delivery promises, per artifact.** Default artifacts are **forever offline** — nothing can remotely stop them, ever. Opt-in `--web-gate` artifacts carry a **cloud kill switch**: flip a toggle in your portal and the app stops everywhere it is deployed, flip it back and it resumes — nothing to re-ship.
- **What you ship keeps working.** Your subscription gates *packaging new artifacts*, not decryption. Apps already delivered to your users keep running even after your subscription ends.
- **Agent-ready.** `magiclock skill` teaches any AI coding agent in your project — Claude Code included — to protect your code and models by itself.
- **Speaks your language.** CLI and portal in English, 简体中文, 繁體中文, 日本語, 한국어, Français.

## Quick start — encrypt Python code in two commands

```shell
pip install magiclock

# First run signs you in and activates this machine, then encrypts.
magiclock protect app.py     # -> app.pya  (encrypted artifact)
magiclock run app.pya        # runs exactly like `python app.py`

# Protect a whole project tree recursively:
magiclock protect src/
```

That's the entire workflow. `.pya` files are ordinary files — commit them, copy them, ship them however you already distribute your app. On any machine you haven't authorized, they decrypt to nothing.

## Encrypt AI models

```shell
magiclock protect-model models/face.onnx    # -> models/face.onnx.enc
```

```python
import magiclock
import onnxruntime

magiclock.bootstrap()                                        # gate up, against this machine's license
model_bytes = magiclock.open_model("models/face.onnx.enc")   # plaintext exists in memory only
session = onnxruntime.InferenceSession(model_bytes)
```

`open_model()` doesn't care what's in the envelope — ONNX, PyTorch state dicts, raw weights, datasets, config bundles. Bytes in, bytes out, never on disk.

## Compile Python to a native binary — the strongest tier

```shell
pip install "magiclock[build]"

magiclock build app.py                       # single native module (.so / .pyd)
magiclock build app.py --standalone          # self-contained app directory
magiclock build app.py --model weights.onnx  # bundle encrypted models into the build
```

`magiclock build` walks every `.py` module reachable from your entry point, inserts a license-gate check into each one, then compiles the result to native code. The output **needs no MagicLock install, no account, and no network** on the machine that runs it.

## Expiry, trials, and stronger locks

```shell
magiclock protect app.py --expires-in 30d       # artifact stops decrypting in 30 days
magiclock protect app.py --expires-at 2026-12-31
magiclock protect app.py --trial                # 48-hour self-destruct — for demos
magiclock protect app.py --lock-passphrase      # machine + passphrase two-factor lock
magiclock protect app.py --no-bind-machine --emit-key   # portable: unlocked by key, not machine
```

## Remotely disable shipped software — the cloud kill switch (`--web-gate`)

```shell
magiclock protect app.py --web-gate
```

A cloud-controlled artifact checks for your approval before it runs. Flip the switch off in your portal and it stops at its next check — everywhere it is deployed. Flip it back on and it resumes. Offline it keeps running through a grace window **you** choose (1 hour to 30 days). Built for rentals, subscriptions, expiring pilots, and unpaid invoices.

Artifacts built *without* the flag stay forever offline and can never be remotely revoked. The choice is per artifact, not per account — mix both in one product line.

## What's in this package

| Import package | Role |
|---|---|
| `magiclock` | The CLI + the runtime: node-lock vault, `.pya` import hook, and the top-level API (`magiclock.bootstrap()` / `magiclock.open_model()`) |
| `magiclock_host` | Tier-neutral runtime SDK: the license gate, transport seam, encrypted-envelope codec |
| `magiclock_channel` | Secure channel: Noise_NK handshake + wire framing |
| `magiclock_build` | Native-binary build/packaging (strong protection tier) — the compiler dependency is the `[build]` extra |

The full command set: `activate / status / deactivate · protect / protect-model / run · build · artifacts · skill · completion`. Authentication is folded into `activate` (device-authorization flow, or `--with-token` for CI); `activate` is idempotent — re-run it to refresh. `deactivate` frees the seat server-side by default. Run `magiclock --help` for everything.

Using an AI coding agent (Claude Code) to protect your project? Run `magiclock skill` once — it installs a project skill that teaches the agent how to pick a protection tier and drive `protect`/`build` correctly against your codebase.

Enable tab completion (bash/zsh):

```shell
magiclock completion bash >> ~/.bashrc    # or: source <(magiclock completion bash)
magiclock completion zsh >> ~/.zshrc      # or: source <(magiclock completion zsh)
```

## Language

CLI messages are available in English, 简体中文, 繁體中文, 日本語, 한국어 and français. The language is picked automatically: set `MAGICLOCK_LANG` (e.g. `zh-Hans`, `zh-TW`, `ja`, `fr`) to force one; otherwise the language preference saved on your account is used after `magiclock activate`, falling back to your system locale, then English. (`--help` text stays English.)

## FAQ

**Do I need to be online to run protected apps?**
No. Activation is online once; after that, protected code and models verify and decrypt fully offline on the authorized machine.

**What happens when my subscription ends?**
Everything you already shipped keeps working — the subscription only gates packaging *new* artifacts, not decryption. Renew when you want to publish again.

**Do my end users need a MagicLock account?**
No. You ship the protected app any way you like; your users need no account and no install (the compiled tier needs no MagicLock package at all on their machine).

**Does my source code or model ever get uploaded?**
No. `protect`, `protect-model`, and `build` run locally. Models decrypt only in memory on the authorized device, and the decryption secret never leaves it — it is never uploaded or escrowed, and no server can hand it over.

**Is the free trial really free?**
Yes — every capability, free for 48 hours on one device, no card. The clock starts when you first activate a machine, not at sign-up. When it ends, everything you built keeps working; you just can't package new artifacts until you subscribe.

**Which Python versions and platforms are supported?**
Python 3.9–3.14 on macOS (Apple Silicon), Windows, and Linux.

**How does MagicLock compare to PyArmor, SOURCEdefender, Nuitka, Cython or PyInstaller?**
Obfuscators transform code but still hand the whole program to whoever holds the file; compilers and packagers solve performance and distribution, not licensing. MagicLock combines encryption, node-locked licensing, and native compilation in one tool — see the [detailed comparisons](https://magiclock.net/compare).

---

## 简体中文

MagicLock 是一款商业工具，用于 **Python 源码加密**、**AI 模型加密**与**软件授权**：一条命令把 `.py` 文件和模型权重变成加密产物，仍像普通 Python 一样导入运行——但只在你授权的设备上。校验与解密**完全离线**：无加密狗、无需自建授权服务器、运行时零联网。订阅只影响打包新产物——已交付给用户的软件永久可用。CLI 与门户支持简体中文（`MAGICLOCK_LANG=zh-Hans`，或跟随账号语言偏好自动切换）。

```shell
pip install magiclock
magiclock protect app.py     # -> app.pya（加密产物）
magiclock run app.pya        # 与 `python app.py` 完全一致地运行
```

🌐 [官网（中文）](https://magiclock.net/zh-Hans) · [文档](https://magiclock.net/zh-Hans/docs) · [定价（48 小时免费试用）](https://magiclock.net/zh-Hans/pricing)

## 繁體中文

MagicLock 是一款商業工具，用於 **Python 原始碼加密**、**AI 模型加密**與**軟體授權**：一條命令把 `.py` 檔案與模型權重變成加密產物，仍像普通 Python 一樣匯入執行——但只在您授權的裝置上。驗證與解密**完全離線**：無加密狗、無需自建授權伺服器、執行時零連網。訂閱只影響封裝新產物——已交付給使用者的軟體永久可用。CLI 與入口網站支援繁體中文（`MAGICLOCK_LANG=zh-Hant`，或跟隨帳號語言偏好自動切換）。

```shell
pip install magiclock
magiclock protect app.py     # -> app.pya（加密產物）
magiclock run app.pya        # 與 `python app.py` 完全一致地執行
```

🌐 [官網（繁體中文）](https://magiclock.net/zh-Hant) · [文件](https://magiclock.net/zh-Hant/docs) · [定價（48 小時免費試用）](https://magiclock.net/zh-Hant/pricing)

## 日本語

MagicLock は **Python ソースコード暗号化**、**AI モデル暗号化**、**ソフトウェアライセンス**のための商用ツールです。コマンド一つで `.py` ファイルとモデルの重みを暗号化アーティファクトに変換 — 通常の Python と同じようにインポート・実行できますが、認可したデバイス上でのみ動作します。検証と復号は**完全オフライン**:ドングル不要、ライセンスサーバーの運用不要、実行時のネットワーク接続ゼロ。サブスクリプションは新規アーティファクトの作成のみに関わり、出荷済みのソフトウェアは永久に動き続けます。CLI とポータルは日本語に対応(`MAGICLOCK_LANG=ja`、またはアカウントの言語設定に自動追従)。

```shell
pip install magiclock
magiclock protect app.py     # -> app.pya(暗号化アーティファクト)
magiclock run app.pya        # `python app.py` と同じように実行
```

🌐 [ウェブサイト(日本語)](https://magiclock.net/ja) · [ドキュメント](https://magiclock.net/ja/docs) · [料金(48 時間無料トライアル)](https://magiclock.net/ja/pricing)

## 한국어

MagicLock 은 **Python 소스 코드 암호화**, **AI 모델 암호화**, **소프트웨어 라이선스**를 위한 상용 도구입니다. 명령 하나로 `.py` 파일과 모델 가중치를 암호화 아티팩트로 변환 — 일반 Python 처럼 임포트하고 실행되지만, 승인한 기기에서만 동작합니다. 검증과 복호화는 **완전 오프라인**: 동글 불필요, 라이선스 서버 운영 불필요, 실행 시 네트워크 연결 없음. 구독은 새 아티팩트 패키징에만 관여하며, 이미 배포한 소프트웨어는 영구히 동작합니다. CLI 와 포털은 한국어를 지원합니다(`MAGICLOCK_LANG=ko`, 또는 계정 언어 설정 자동 적용).

```shell
pip install magiclock
magiclock protect app.py     # -> app.pya(암호화 아티팩트)
magiclock run app.pya        # `python app.py` 와 동일하게 실행
```

🌐 [웹사이트(한국어)](https://magiclock.net/ko) · [문서](https://magiclock.net/ko/docs) · [가격(48시간 무료 체험)](https://magiclock.net/ko/pricing)

## Français

MagicLock est un outil commercial de **chiffrement de code source Python**, de **chiffrement de modèles d'IA** et de **licences logicielles** : une seule commande transforme vos fichiers `.py` et vos poids de modèles en artefacts chiffrés qui s'importent et s'exécutent comme du Python ordinaire — mais uniquement sur les appareils que vous autorisez. Vérification et déchiffrement **entièrement hors ligne** : pas de dongle, pas de serveur de licences à héberger, zéro connexion réseau à l'exécution. L'abonnement ne conditionne que l'empaquetage de nouveaux artefacts — les logiciels déjà livrés fonctionnent pour toujours. CLI et portail disponibles en français (`MAGICLOCK_LANG=fr`, ou automatiquement selon la préférence de langue du compte).

```shell
pip install magiclock
magiclock protect app.py     # -> app.pya (artefact chiffré)
magiclock run app.pya        # s'exécute exactement comme `python app.py`
```

🌐 [Site web (français)](https://magiclock.net/fr) · [Documentation](https://magiclock.net/fr/docs) · [Tarifs (essai gratuit de 48 h)](https://magiclock.net/fr/pricing)

---

## Links

- 🌐 Website: **[magiclock.net](https://magiclock.net)**
- 📚 Documentation: **[magiclock.net/docs](https://magiclock.net/docs)**
- 💰 Pricing (48 h free trial, subscriptions, Lifetime): **[magiclock.net/pricing](https://magiclock.net/pricing)**
- 🐛 Bugs & questions: [github.com/ruisv/magiclock/issues](https://github.com/ruisv/magiclock/issues)

MagicLock is commercial, proprietary software — see [magiclock.net/pricing](https://magiclock.net/pricing).
