IP address encryption and obfuscation methods
Project description
IPCrypt
A Python implementation of IP address encryption and obfuscation methods as defined in the IPCrypt specification.
Features
IPCrypt provides several methods for encrypting and obfuscating IP addresses:
- Deterministic: Deterministic, format-preserving IP address encryption
- ND (Non-deterministic): Non-deterministic IP address encryption with random padding
- NDX (Non-deterministic Extended): Extended non-deterministic encryption with variable-length output
- PFX (Prefix-preserving): Prefix-preserving IP address encryption
All methods support both IPv4 and IPv6 addresses.
Installation
Install using pip:
pip install ipcrypt
Usage
Deterministic Encryption
from ipcrypt import deterministic_encrypt, deterministic_decrypt
# Encrypt an IP address
key = b'sixteen byte key' # 16-byte key for AES-128
encrypted = deterministic_encrypt('192.168.1.1', key)
print(f"Encrypted: {encrypted}")
# Decrypt it back
decrypted = deterministic_decrypt(encrypted, key)
print(f"Decrypted: {decrypted}")
Non-deterministic Encryption (ND)
from ipcrypt import nd_encrypt, nd_decrypt
key = b'sixteen byte key'
encrypted = nd_encrypt('192.168.1.1', key)
print(f"Encrypted: {encrypted}")
decrypted = nd_decrypt(encrypted, key)
print(f"Decrypted: {decrypted}")
Non-deterministic Extended (NDX)
from ipcrypt import ndx_encrypt, ndx_decrypt
key = b'sixteen byte key'
encrypted = ndx_encrypt('192.168.1.1', key)
print(f"Encrypted: {encrypted}")
decrypted = ndx_decrypt(encrypted, key)
print(f"Decrypted: {decrypted}")
Prefix-preserving Encryption (PFX)
from ipcrypt import pfx_encrypt, pfx_decrypt
key = b'sixteen byte key'
prefix_len = 8 # Preserve first 8 bits
# Encrypt while preserving prefix
encrypted = pfx_encrypt('192.168.1.1', key, prefix_len)
print(f"Encrypted: {encrypted}")
# Decrypt it back
decrypted = pfx_decrypt(encrypted, key, prefix_len)
print(f"Decrypted: {decrypted}")
Requirements
- Python 3.8 or higher
- cryptography >= 41.0.0
- pycryptodome >= 3.18.0
Development
To set up a development environment:
# Clone the repository
git clone https://github.com/ipcrypt-std/draft-denis-ipcrypt
cd draft-denis-ipcrypt/implementations/python
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
ruff check .
black --check .
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please see the contributing guidelines for more information.
Links
Project details
Release history Release notifications | RSS feed
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 ipcrypt-0.1.0.tar.gz.
File metadata
- Download URL: ipcrypt-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9a6c782d0d584a35909212a4d936e8b2ef43c19fb1b51813599fabd0de23453
|
|
| MD5 |
48ebfc9e221a0ffbac3424f2956ff299
|
|
| BLAKE2b-256 |
1be19b1b4c876f7cf6cc46727eef2000e93f045a3d496fbd94b73e9b2a609396
|
File details
Details for the file ipcrypt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipcrypt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e0761bfe3181f8833e2c8d754f745364eee9285e7741d470d9e4f183b042116
|
|
| MD5 |
2980df83fcc8d01dc6d1089ed4b745f3
|
|
| BLAKE2b-256 |
19a3528ca8a2b9c74cbd88643c0c368c7aee72c774f99848c166e68bc74c2dda
|