News for hackers. Stuff that matters.
Re:There’s more than one way to write an IP address by maddyboo on Wednesday July 10, 2019 @02:44AM (#20399669)
This is neat!

Here's a JS version:

  > const ip2dec = ip => ip.split(".").reverse().reduce((acc, n, i) => acc + (parseInt(n) * (2 ** (i * 8))), 0)
  > ip2dec("192.168.0.1")
  3232235521
  > ip2dec("192.168.1.1")
  3232235777
  > ip2dec("0xDE.0xAD.0xBE.0xEF")
  3735928559

There are no comments on this comment yet.