Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How can I encode any ip address?


The normal way of displaying the ip address for HN is `184.172.10.74`. You then just have to take each 4 parts and multiply it with a power of 256:

    184 * 256^3 + 172 * 256^2 + 10 * 256^1 + 74 * 256^0 == 3098282570


In python: struct.unpack(">I", struct.pack("BBBB", 184, 172, 10, 74))


Dot to decimal/hex/octal format conversion, and vice versa. You can use online tools like these:

http://www.kloth.net/services/iplocate.php


Google for "ip to long"...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: