Metadata-Version: 2.4
Name: mapping-encrypt
Version: 0.1.0
Summary: A custom character encoding package for encrypting Python scripts
Home-page: https://github.com/mfq2412/Mapping
Author: MD Faisal Qureshi
Author-email: mfq2412@example.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rich
Requires-Dist: pandas
Requires-Dist: openpyxl
Requires-Dist: requests
Requires-Dist: urllib3
Requires-Dist: firebase-admin
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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

```bash
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

```bash
mapping-encode script.py -o encrypted.py
```

---

### 3️⃣ Run Encrypted Script

```bash
python encrypted.py
```

---

## 📖 Complete Example

### Original Script (`hello.py`)
```python
print("Hello, World!")
```

### Encrypt It
```bash
mapping-encode hello.py -o hello_encrypted.py
```

### Encrypted Script (`hello_encrypted.py`)
```python
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
```bash
python hello_encrypted.py
# Output: Hello, World!
```

---

## 🔐 How to Encrypt & Decrypt

### Encrypt (Encode)
```bash
# 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)
```python
import mapping

# Decode a string
encoded = "za0A|x8LR|ey1C|ey1C|8t5s"
decoded = mapping.decode(encoded)
print(decoded)  # Output: "hello"
```

### Encode Text
```python
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:

```python
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

1. Go to: https://github.com/settings/tokens
2. Click **Generate new token (classic)**
3. Settings:
   - **Note**: `Mapping Package`
   - **Expiration**: 7 days
   - **Scope**: ✅ `repo` only
4. **Copy the token**

### Step 2: Clean Install (Recommended)

**First, remove any old versions:**

```bash
# Remove old/conflicting packages
pip uninstall -y mapping-encrypt mapping_package mapping
```

**Then install fresh:**

```bash
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
```

**Example:**
```bash
pip uninstall -y mapping-encrypt mapping_package mapping
pip install git+https://ghp_abc123xyz789@github.com/mfq2412/Mapping.git
```

### Step 3: Verify Installation

```bash
python -c "import mapping; print('✅ Installed!')"
```

### Step 4: Delete Token

After installation, delete your token at: https://github.com/settings/tokens

---

## 📝 Command-Line Options

```bash
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:**
```bash
# 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.json` is 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

1. **Generate short-lived tokens** (1-7 days)
2. **Delete tokens after installation**
3. **Never share your mapping.json**
4. **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:

```bash
# 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

```bash
pip show mapping-encrypt
```

### Update to Latest Version

```bash
# Remove old version
pip uninstall -y mapping-encrypt

# Install latest
pip install git+https://YOUR_TOKEN@github.com/mfq2412/Mapping.git
```

### Complete Clean Reinstall

```bash
# 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:**
1. Re-encrypt your original Python file with the updated mapping:
```bash
# 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
```

2. 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:
```bash
mapping-encode script.py -o encrypted.py --update-mapping
```

---

## 🗑️ Uninstall

### Standard Uninstall (All Platforms)

```bash
# 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:

```bash
# 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:**
```bash
# Manually remove shim
rm ~/.pyenv/shims/mapping-encode

# Rehash again
pyenv rehash
```

#### Windows

```cmd
# Uninstall package
pip uninstall -y mapping-encrypt

# Verify removal
pip list | findstr mapping
```

**If command still exists:**
```cmd
# 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:

```bash
# 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:**
```bash
# 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:

```bash
# 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:

```bash
# 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**

```bash
# 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**

```bash
# 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**

```bash
# 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.
