Python library for anonymizing IP addresses
Project description
anonymize_ip
This is a simple Python library for anonymizing IP addresses. Both IPv4 and IPv6 addresses are supported.
Examples:
- IPv4:
95.239.169.11
→95.239.169.0
- IPv6:
5219:3a94:fdc5:19e1:70a3:b2c4:40ef:ae03
→5219:3a94:fdc5:19e1::
Usage
pip install anonymizeip
from anonymizeip import anonymize_ip
address = "fe80::0202:b3ff:fe1e:8329"
anonymized = anonymize_ip(address)
print(anonymized)
# Prints "fe80::"
Settings
The number of address blocks that are set to 0 can be customized.
Besides the IP address, the function anonymize_ip
takes two optional parameters:
anonymize_ip(
address,
ipv4_mask="...",
ipv6_mask="..."
)
ipv4_mask
: Defaults to255.255.255.0
, i.e. the last octet will be anonymized (set to 0)ipv6_mask
: Defaults toffff:ffff:ffff:ffff::
(same asffff:ffff:ffff:ffff:0:0:0:0
), i.e. the last four blocks will be anonymized (set to 0)
Development
git clone
pipenv install --dev
- Make your code modifications
pipenv run test
pipenv run lint
Contributions are always welcome. Please first discuss changes via issue before submitting a pull request.
Credits
The implementation of this library was strongly inspired by php-ip-anonymizer by Geert Wirken.
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
anonymizeip-1.0.0.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file anonymizeip-1.0.0.tar.gz
.
File metadata
- Download URL: anonymizeip-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 491cb94a31bae23294c5b93a13dd5c9ed55be98003c622e76e2fe64d6a4f3e91 |
|
MD5 | 063eb7d8e567b622285697b5e9ba2b9d |
|
BLAKE2b-256 | 4a055987ce97a2a8debfba16e35efa88975f340559337b7faabb24e78b32f8c6 |
File details
Details for the file anonymizeip-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: anonymizeip-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0d446b06b2bbf236394a90b971de403f90f805d14db3a405f8731716acad1fe |
|
MD5 | a2c39bb478df8ad2752d99dbed7b59d7 |
|
BLAKE2b-256 | e27427c04c380b9e5d40de1643677f07b54bda2733b33cabba809214405a737e |