Goldenmask: Protect your python source code
Goldenmask is a tool to protect your python source code easily. It has two methods at the moment: using Compileall or using Cython. It has a corresponding option named --layer/-l, you can choose your favorite method by yourself. Meanwhile, it can protect different file types: python files end with .py, wheel packages end with .whl and source package end with .tar.gz.
Goldenmask is a name derived from a Chinese kungfu named "JinZhongZhao". Because it is not a qualified phrase in a sense, this name is so unique that can be used as a temporary compilation directory named __goldenmask__ and a compilation information file named .goldenmask which contains the detailed python version string (from sys.version) and the platform string (from platform.unmae()) .
Let's try to goldenmask now!
Quick Start
$ pip install goldenmask
# 默认方法是使用 Compileall 编译为 pyc
$ goldenmask yourpythonfile.py
All done! ✨ 🍰 ✨
$ tree -a .
.
├── __goldenmask__
│ ├── .goldenmask
│ └── yourpythonfile.pyc
└── yourpythonfile.py
1 directory, 3 files
# 用生成的 .so 文件替换原始的 py 文件
$ goldenmask -i -l 2 yourpythonfile.py
All done! ✨ 🍰 ✨
$ tree -a .
.
├── .goldenmask
└── yourpythonfile.so
0 directories, 2 files
Installation
Goldenmask is distributed on PyPI and supports Python 3.6+. You can simply install goldenmask as below:
$ pip install -U goldenmask
However, it's a better choice to use a virtual environment:
$ python -m venv env
# On Windows:
$ .\venv\Scripts\activate
# On Linux:
$ source env/bin/activate
$ pip install goldenmask --upgrade
Because goldenmask depends on Cython, you should make sure that there is an appropriate C compiler on your machine. You can see the detailed guide on Cython's documentation. By the way, if you works on a Linux system, you can easily fetch everything you need with one command sudo apt-get install build-essential on Ubuntu and yum groupinstall "Development Tools" on Centos. However, If you are using Mac OS X or Windows, you may spend quite some time installing this compilers.
Usage
You can get everything using option --help:
$ goldenmask --help
Usage: goldenmask [OPTIONS] [FILES_OR_DIRS]...
Goldenmask is a tool to protect your python source code easily.
FILES_OR_DIRS can be python files, wheel packages,source packages or dirs
contain python files.
Options:
-l, --layer <int> Level of protection: 1 - compileall; 2 - cython.
-i, --inplace Whether compile python files in place.
--no_smart This will copy and compile everything you specified.
--help Show this message and exit.
portect the wheel package:
$ goldenmask goldenmask-0.2.1-py3-none-any.whl
All done! ✨ 🍰 ✨
$ tree -a .
.
├── __goldenmask__
│ ├── .goldenmask
│ └── goldenmask-0.2.1-py3-none-any.whl
├── .goldenmask
└── goldenmask-0.2.1-py3-none-any.whl
1 directory, 4 files
protect the source packege:
$ goldenmask -l 2 --inplace goldenmask-0.1.2.tar.gz
running build_ext
building 'goldenmask.cli' extension
...
All done! ✨ 🍰 ✨
$ tree -a .
.
├── .goldenmask
└── goldenmask-0.1.2.tar.gz
protect the dir contians python files:
$ goldenmask pip-download/
All done! ✨ 🍰 ✨
Contribute
Goldenmask uses Poetry to develop, you can follow these steps to get involved:
- fork the project goldenmask
- clone the forked project
- install Poetry
- run
poetry installto install dependencies,modify the code, run the tests and finally submit pull requests
Credits
Metadata
Release files for goldenmask 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| goldenmask-0.2.1.tar.gz | 14.4 kB | Without provenance | Details for goldenmask-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| goldenmask-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for goldenmask-0.2.1-py3-none-any.whl |
Total release size: 29.1 kB
Release files / goldenmask-0.2.1.tar.gz
| Download URL | goldenmask-0.2.1.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abd302ac2846bf3f70fd8b6f20926e35e5b593c101cb9a15d7ee9b1b38abb66a
|
|
BLAKE2b-256 checksum How to use checksums |
fde77482f759867cb1f9f1174f84c5965f73bf1fd511f96969bee888dac9de32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.2 Linux/5.0.0-1032-azure
|
Release files / goldenmask-0.2.1-py3-none-any.whl
| Download URL | goldenmask-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0a7c2c5d370dd85a56dce284d9201cbf90c4656bea1d5fc60ab53e25d854420
|
|
BLAKE2b-256 checksum How to use checksums |
7b8c2839589ff341e1d5be58fc1ecef32ccfead7c192df9170fd8b32975ce445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.2 Linux/5.0.0-1032-azure
|
Security for goldenmask 0.2.1
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.