Created
January 19, 2016 14:35
-
-
Save packetchef/0d301522b1fc4735bed5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import struct | |
def ip2dec(ip): | |
packedIP = socket.inet_aton(ip) | |
return struct.unpack("!L", packedIP)[0] | |
def dec2ip(dec): | |
return socket.inet_ntoa(struct.pack("!L", dec)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment