Keeping sensitive source encrypted on disk while still running Python code
AI coding tools need to read project files. Some source code should still stay out of the workspace in plaintext.
I built AILatch for that boundary: files stay encrypted on disk, while Python code can run with plaintext materialized only inside the AILatch process.
The basic flow is:
pip install ailatch ailatch lock secret.py cat secret.py # ordinary file reads see ciphertext ailatch run secret.py # run the program without restoring plaintext ailatch run decrypts the entry file in memory and keeps the working-tree file encrypted. Encrypted Python modules can still import each other, and application code can use normal open() and pathlib reads through the runtime hooks.
When I need to inspect or edit a locked file, AILatch provides a controlled plaintext view:
ailatch open . ailatch show secret.py The project also includes encrypted backups and recovery commands:
ailatch lock secret.py --recovery ailatch restore secret.py ailatch recover secret.py This is aimed at filesystem-level reads by AI tools and ordinary file utilities. It does not claim to stop a privileged local attacker who can inspect process memory or persuade a user to decrypt a file. Stronger isolation still requires operating-system permissions, process isolation, and careful credential handling.
AILatch currently targets Python 3.11+ and is primarily tested on Windows and macOS.
Repository and full command reference: github.com/lo2589/AILatch
Tags: #opensource #python #security #ai