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
Release files for ipcrypt 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipcrypt-0.1.0.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipcrypt-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / ipcrypt-0.1.0.tar.gz
| Download URL | ipcrypt-0.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9a6c782d0d584a35909212a4d936e8b2ef43c19fb1b51813599fabd0de23453
|
|
BLAKE2b-256 checksum How to use checksums |
1be19b1b4c876f7cf6cc46727eef2000e93f045a3d496fbd94b73e9b2a609396
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / ipcrypt-0.1.0-py3-none-any.whl
| Download URL | ipcrypt-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e0761bfe3181f8833e2c8d754f745364eee9285e7741d470d9e4f183b042116
|
|
BLAKE2b-256 checksum How to use checksums |
19a3528ca8a2b9c74cbd88643c0c368c7aee72c774f99848c166e68bc74c2dda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|