Skip to content

Instantly share code, notes, and snippets.

@packetchef
Created July 23, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save packetchef/1a84bfd33bdfeeccf591 to your computer and use it in GitHub Desktop.
Save packetchef/1a84bfd33bdfeeccf591 to your computer and use it in GitHub Desktop.
For a given subnet and salt, mask each IP
# Rumor has it that in newer releases of Python v3, ipaddr objects are not iterable
import ipaddr
import hashlib
salt = 'NN'
subnet = ipaddr.IPNetwork('192.168.100.0/24')
for ip in subnet:
# Try md5 or sha512
maskedIP = hashlib.md5(str(ip) + salt).hexdigest()
print('{ip:<15} :: {maskedIP}'.format(ip=ip, maskedIP=maskedIP))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment