2017 © Pedro Peláez
 

library ip-anonymizer

IPv4 and IPv6 address anonymizer

image

potaka/ip-anonymizer

IPv4 and IPv6 address anonymizer

  • Sunday, May 13, 2018
  • by po_taka
  • Repository
  • 1 Watchers
  • 0 Stars
  • 392 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 5 Versions
  • 989 % Grown

The README.md

Build Status, (*1)

IP address anonymizer for PHP

This is a library for PHP to anonymize IP addresses. This makes it easier to respect user privacy, and it makes it more difficult to identify an end user by his IP address. Anonymizing IP addresses can be useful for a lot of cases where the exact IP address is not important or even undesired, for example in a statistical analysis., (*2)

This library supports both IPv4 and IPv6 addresses. Addresses are anonymized to their network ID., (*3)

The default settings anonymize an IP address to a /24 subnet (IPv4) or a /64 subnet (IPv6), but these can be customized., (*4)

For instance, the IPv4 address 192.168.178.123 is anonymized by default to 192.168.178.0., (*5)

The IPv6 address 2a03:2880:2110:df07:face:b00c::1 is anonymized by default to 2610:28:3090:3001::., (*6)

Example

<?php
use Potaka\IpAnonymizer\IpAnonymizer;

$ipAnonymizer = new IpAnonymizer();

var_dump($ipAnonymizer->anonymize('127.0.0.1'));
// returns 127.0.0.0

var_dump($ipAnonymizer->anonymize('192.168.178.123'));
// returns 192.168.178.0

var_dump($ipAnonymizer->anonymize('8.8.8.8'));
// returns 8.8.8.0

var_dump($ipAnonymizer->anonymize('::1'));
// returns ::

var_dump($ipAnonymizer->anonymize('::127.0.0.1'));
// returns ::

var_dump($ipAnonymizer->anonymize('2a03:2880:2110:df07:face:b00c::1'));
// returns 2a03:2880:2110:df07::

var_dump($ipAnonymizer->anonymize('2610:28:3090:3001:dead:beef:cafe:fed3'));
// returns 2610:28:3090:3001::

// Use a custom mask:
$ipAnonymizer->ipv4NetMask = "255.255.0.0";
var_dump($ipAnonymizer->anonymize('192.168.178.123'));
// returns 192.168.0.0

// You can use this class also in a static way:
var_dump(IpAnonymizer::anonymizeIp('192.168.178.123'));
// returns 192.168.178.0

var_dump(IpAnonymizer::anonymizeIp('2610:28:3090:3001:dead:beef:cafe:fed3'));
// returns 2610:28:3090:3001::

License

This library is licensed under the MIT License. See the LICENSE file for the full license., (*7)

The Versions

13/05 2018

dev-master

9999999-dev

IPv4 and IPv6 address anonymizer

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Geert Wirken

13/05 2018

2.0.0

2.0.0.0

IPv4 and IPv6 address anonymizer

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Geert Wirken

13/05 2018

dev-initial

dev-initial

IPv4 and IPv6 address anonymizer

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Geert Wirken

24/06 2017

v1.1.0

1.1.0.0

IPv4 and IPv6 address anonymizer

  Sources   Download

MIT

by Geert Wirken

27/10 2016

v1.0.0

1.0.0.0

IPv4 and IPv6 address anonymizer

  Sources   Download

MIT

by Geert Wirken