Coder Social home page Coder Social logo

anonymize-ip's Introduction

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 to 255.255.255.0, i.e. the last octet will be anonymized (set to 0)
  • ipv6_mask: Defaults to ffff:ffff:ffff:ffff:: (same as ffff:ffff:ffff:ffff:0:0:0:0), i.e. the last four blocks will be anonymized (set to 0)

Development

  1. git clone
  2. pipenv install --dev
  3. Make your code modifications
  4. pipenv run test
  5. 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.

anonymize-ip's People

Contributors

dependabot[bot] avatar samuelmeuli avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.