[ Align to Top ] One Large Number

Method for converting an IP number [165.166.140.250] into a single large number [2779155706] and back again. Technique courtesy of "Spam Dog" in news.admin.net-abuse.email.

Encoding

Ok, Here is the full blown explanation for those that like solving mental puzzles. Lets say you have an IP address of 165.166.140.250, and you want to encode it The process is:

Line the IP address (165.166.140.250) in a vertical line like this:

165.
166.
140.
250

Now multiply as follows:

165 * 256 * 256 * 266 = 2768240640
166 * 256 * 256 =	10878976
140 * 256 = 		35840
250 * 1 =		250

Now add them together:

2768240640 + 10878976 + 35840 + 250 = 2779155706

Pretty straightforward, huh?


[ Align to Top ] Decoding

Now for the decode, re-creating the original four octets:

First Octet

Take the decimal IP number (2779155706) and do this:

2779155706 / 256 / 256 / 256 = 165

165! This is good! We are one fouth there. Next -- remove this value from the original number!

Now multiply 165 * 256 * 256 * 256

165 * 256 * 256 * 256 = 2768240640

Take the original decimal number (2779155706) and subtract the result above (2768240640)

2779155706 - 2768240640 = 10915066

That leaves 10915066, the quantity that is still encoded. This will be used to calculate the second octet in the IP number.

Second Octet

Now divide 10915066 like this:

10915066 / 256 / 256 = 166

Ah ha! 166! We are getting there! Now on to octet number three by first finding the quantity that is still encoded.

166 * 256 * 256 = 10878976

Subtract 10878976 from 10915066

10915066 - 10878976 = 36090

Third Octet

Now divide 36090 by 256

36090 / 256 = 140

140! This is good. One remaining octet to calculate.

140 * 256 = 35840

Fourth Octet

Subtract 35840 from 36090

36090 - 35840 = 250

and you have the original IP of:


165
166
140
250

or re-assembled: 165.166.140.250

So the next time you get one of those spams with that nasty decimal IP address just reach for a pencil and paper, put those rusty brain cells to work, and do the math...................................or then again you could do what I do and just paste it to the end of traceroute and press ENTER.

Internet Data Mining Contents Copyright © 1998, 1999, 2000, 2001, 2002 by George Crissman. All rights reserved worldwide. Page design by George Crissman, strads@tmisnet.com, updated 4/30/2002.