A custom character encoding package for encrypting Python scripts
Project description
Mapping - Python Script Encryption Tool
A private custom character encoding package for encrypting Python scripts using a secret mapping system.
⚠️ PRIVATE REPOSITORY - Requires GitHub Personal Access Token to install.
🚀 Quick Start
1️⃣ Install Package
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
Get Token: https://github.com/settings/tokens (Scope: repo, Expiration: 7 days)
2️⃣ Encrypt Your Script
mapping-encode script.py -o encrypted.py
3️⃣ Run Encrypted Script
python encrypted.py
📖 Complete Example
Original Script (hello.py)
print("Hello, World!")
Encrypt It
mapping-encode hello.py -o hello_encrypted.py
Encrypted Script (hello_encrypted.py)
import mapping
encoded_string = "PsKC|LU7q|l1Bm|8t5s|x90E|Imb6|fD7w|Gv5C|x90E|Imb6|8t5s|7P6C|Jy2b|1hAT|9Ig0|SojR|SojR|Imb6|l1Bm|1hAT|8t5s|fR2V"
decoded_string = mapping.decode(encoded_string)
exec(decoded_string)
Run It
python hello_encrypted.py
# Output: Hello, World!
🔐 How to Encrypt & Decrypt
Encrypt (Encode)
# Command-line
mapping-encode my_script.py -o encrypted_script.py
# Python
from mapping.encoder import encode_file
encode_file("my_script.py", "encrypted_script.py")
Decrypt (Decode)
import mapping
# Decode a string
encoded = "za0A|x8LR|ey1C|ey1C|8t5s"
decoded = mapping.decode(encoded)
print(decoded) # Output: "hello"
Encode Text
import mapping
# Encode a string
text = "hello"
encoded = mapping.encode(text)
print(encoded) # Output: "za0A|x8LR|ey1C|ey1C|8t5s"
📋 Encrypted Script Template
Every encrypted script follows this simple pattern:
import mapping
encoded_string = "YOUR_ENCODED_STRING_HERE"
decoded_string = mapping.decode(encoded_string)
exec(decoded_string)
That's it! Just replace YOUR_ENCODED_STRING_HERE with your encrypted code.
🛠️ Installation Steps
Step 1: Generate Personal Access Token
- Go to: https://github.com/settings/tokens
- Click Generate new token (classic)
- Settings:
- Note:
Mapping Package - Expiration: 7 days
- Scope: ✅
repoonly
- Note:
- Copy the token
Step 2: Clean Install (Recommended)
First, remove any old versions:
# Remove old/conflicting packages
pip uninstall -y mapping-encrypt mapping_package mapping
Then install fresh:
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
Example:
pip uninstall -y mapping-encrypt mapping_package mapping
pip install git+https://ghp_abc123xyz789@github.com/mfq2412/Mapping.git
Step 3: Verify Installation
python -c "import mapping; print('✅ Installed!')"
Step 4: Delete Token
After installation, delete your token at: https://github.com/settings/tokens
📝 Command-Line Options
mapping-encode [-h] [-o OUTPUT] [-u] input
Arguments:
input Input Python file to encrypt
Options:
-h, --help Show help
-o OUTPUT Output file (default: input_encrypted.py)
-u, --update-mapping Add new characters to mapping
Examples:
# Basic
mapping-encode script.py
# Custom output
mapping-encode script.py -o my_encrypted.py
# Update mapping for new characters
mapping-encode script.py --update-mapping
🔒 Security
This is a private encryption tool:
- ✅ Private Repository - Requires token to access
- ✅ Secret Mapping - Your
mapping.jsonis private - ✅ Access Control - Only you can install and use
- ✅ Temporary Tokens - Create, use, delete
Keep your repository PRIVATE! Without access to your private repo, no one can decode your encrypted scripts.
💡 Usage Tips
- Generate short-lived tokens (1-7 days)
- Delete tokens after installation
- Never share your mapping.json
- Keep repository private
📁 Project Structure
Mapping/
├── mapping/
│ ├── __init__.py # Decode/encode functions
│ ├── encoder.py # CLI encoder tool
│ └── mapping.json # Secret character mapping
├── setup.py # Package configuration
└── README.md # This file
⚡ Quick Reference
| Task | Command |
|---|---|
| Install | pip install git+https://TOKEN@github.com/mfq2412/Mapping.git |
| Uninstall | pip uninstall -y mapping-encrypt |
| Update | pip install --upgrade git+https://TOKEN@github.com/mfq2412/Mapping.git |
| Encrypt | mapping-encode script.py -o encrypted.py |
| Run | python encrypted.py |
| Decode | mapping.decode(encoded_string) |
| Encode | mapping.encode(text) |
🔧 Troubleshooting
Error: "characters not in mapping"
This usually means you have an old version installed. Fix it:
# Remove ALL old packages
pip uninstall -y mapping-encrypt mapping_package mapping
# Reinstall from GitHub
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
# Verify
python -c "import mapping; print('✅ Fixed!')"
Check Installed Version
pip show mapping-encrypt
Update to Latest Version
# Remove old version
pip uninstall -y mapping-encrypt
# Install latest
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
Complete Clean Reinstall
# 1. Remove everything
pip uninstall -y mapping-encrypt mapping_package mapping
# 2. Clear pip cache (optional)
pip cache purge
# 3. Fresh install
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
SyntaxError: invalid syntax with ? character
If you see errors like:
SyntaxError: invalid syntax
mac = ':'.join(['{:02x}'.format((uuid.getnode() >> elements) ? 0xff)
^
This means your encrypted file was created with an old mapping that's missing some characters (like &). The ? appears where the missing character should be.
Solution:
- Re-encrypt your original Python file with the updated mapping:
# Make sure you have the latest version
pip install --upgrade git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
# Re-encrypt your script (use --update-mapping to add missing characters)
mapping-encode your_script.py -o encrypted.py --update-mapping
- If you don't have the original file, you'll need to fix the encrypted file manually or recover the original source.
Prevention: Always use --update-mapping flag when encoding files that might contain new characters:
mapping-encode script.py -o encrypted.py --update-mapping
🗑️ Uninstall
Standard Uninstall (All Platforms)
# Uninstall the package
pip uninstall -y mapping-encrypt
# Verify removal
pip list | grep mapping
Important: The package name is mapping-encrypt, not mapping or mapping_package.
Platform-Specific Cleanup
macOS / Linux with pyenv
If you're using pyenv, you may need to refresh the shims:
# Uninstall package
pip uninstall -y mapping-encrypt
# Refresh pyenv shims
pyenv rehash
# Verify command is removed
which mapping-encode
# Should output: mapping-encode not found
If stale shim persists:
# Manually remove shim
rm ~/.pyenv/shims/mapping-encode
# Rehash again
pyenv rehash
Windows
# Uninstall package
pip uninstall -y mapping-encrypt
# Verify removal
pip list | findstr mapping
If command still exists:
# Clear pip cache
pip cache purge
# Reinstall and uninstall to clear registry
pip install git+https://TOKEN@github.com/mfq2412/Mapping.git
pip uninstall -y mapping-encrypt
Virtual Environments
If installed in a virtual environment:
# Activate your venv first
source venv/bin/activate # macOS/Linux
# OR
venv\Scripts\activate # Windows
# Then uninstall
pip uninstall -y mapping-encrypt
# Deactivate venv
deactivate
Complete venv cleanup:
# Just delete the entire venv folder
rm -rf venv # macOS/Linux
rmdir /s venv # Windows
Complete System Cleanup
For a thorough cleanup across all environments:
# 1. Uninstall the package
pip uninstall -y mapping-encrypt
# 2. Clear pip cache
pip cache purge
# 3. Check for any remaining installations
pip list | grep -i mapping
# 4. For pyenv users (macOS/Linux)
pyenv rehash
rm -f ~/.pyenv/shims/mapping-encode
# 5. Verify complete removal
python -c "import mapping" 2>&1
# Should output: ModuleNotFoundError: No module named 'mapping'
Verification
After uninstall, verify everything is removed:
# Check package list
pip list | grep mapping # Should show nothing
# Check command availability
mapping-encode --version # Should fail
# Check import
python -c "import mapping" # Should fail
Troubleshooting Uninstall Issues
Issue: Command still available after uninstall
# For pyenv users
pyenv rehash
rm ~/.pyenv/shims/mapping-encode
# For standard Python
which mapping-encode # Find the location
rm $(which mapping-encode) # Remove it manually
Issue: Module still imports
# Find where it's installed
python -c "import mapping; print(mapping.__file__)"
# Remove that directory manually
rm -rf /path/to/mapping/directory
Issue: Multiple Python environments
# Check all Python environments
python --version
python3 --version
# Uninstall from each
python -m pip uninstall -y mapping-encrypt
python3 -m pip uninstall -y mapping-encrypt
Note: The package name is mapping-encrypt for pip, but imports as mapping in Python.
📞 Support
This is a private tool for personal use.
- Keep repository PRIVATE
- Use temporary tokens
- Never share mapping.json
Created for personal Python script encryption.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mapping_encrypt-0.1.0.tar.gz.
File metadata
- Download URL: mapping_encrypt-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
967d25feddf28f2bd150ac80aa4e02f95253627f3bf138466172993ec738797c
|
|
| MD5 |
0c850e5c39bce785e2714b952c961794
|
|
| BLAKE2b-256 |
7a886219db21f68ad91f58f1396efe9787d3b103950c8ccac3162058048b0c61
|
File details
Details for the file mapping_encrypt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mapping_encrypt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01f6e9f522ad099f15bb43476c7af2459557f7f0eae6f1b32536b8d9a0aada31
|
|
| MD5 |
b3812c23857150987199719019df0b29
|
|
| BLAKE2b-256 |
d39186cdd087bb1b2498ff6c4b85e31be666bff66a0e4312c8c7cdf3bf53e123
|