Go to top

# Mobile IMEI Validation

, 21 Dec 2011
 Rate this:
We all know that every Mobile Module has one unique number, i.e., IMEI(International Mobile Equipment Identity). The IMEI (14 decimal digits plus a check digit) or IMEISV (16 digits) includes information on the origin, model, and serial number of the device.

Now I am going to tell the Luhn checksum/check digit validation for the given IMEI no.

```one can calculate the IMEI by choosing the check digit that would give a sum divisible by 10. For the example IMEI 49015420323751?,
IMEI	49015420323751?
Double every other
4 18 0 2 5 8 2 0 3 4 3 14 5 2  ?
Sum digits: 4 + (1 + 8) + 0 + 2 + 5 + 8 + 2 + 0 + 3 + 4 + 3 + (1 + 4) + 5 + 2 + ? = 52 + ?
To make the sum divisible by 10, we set ? = 8, so the IMEI is 490154203237518.```

The below code is written in C#, for Check Digit Calculation.

```private Boolean ValidateIMEI(string IMEI)
{
if (IMEI.Length != 15)
return false;
else
{
Int32[] PosIMEI = new Int32[15];
for (int innlop = 0; innlop < 15; innlop++)
{
PosIMEI[innlop] = Convert.ToInt32(IMEI.Substring(innlop, 1));
if (innlop % 2 != 0) PosIMEI[innlop] = PosIMEI[innlop] * 2;
while (PosIMEI[innlop] > 9) PosIMEI[innlop] = (PosIMEI[innlop] % 10) + (PosIMEI[innlop] / 10);
}

Int32 Totalval = 0;
foreach (Int32 v in PosIMEI) Totalval += v;
if (0 == Totalval % 10)
return true;
else
return false;
}

}```

Thanks..,

*** Alternatives are welcome.

## Share

Software Developer (Senior)
India
No Biography provided

## You may also be interested in...

### IDC: How Red Hat's JBoss Enterprise Application Platform is Extending Business Value

 First Prev Next
 my java implementation [modified] gemu 16-Oct-13 10:24
 Reason for my vote of 5 Nice Tip/Trick thatraja 26-Jan-12 22:23
 Re: Thanks Raja --RA Rajesh Anuhya 26-Jan-12 22:29
 Reason for my vote of 5 helpfull m9gi 8-Jan-12 3:29
 Re: Thanks m9gi Rajesh Anuhya 19-Jan-12 0:14
 Re: Thanks Sridhar Rajesh Puli 2-Jan-12 16:10
 Good work. JigneshSE 26-Dec-11 17:48
 Good one, nice to know how to validate IMEI numbers danlobo 18-Dec-11 23:29
 Last Visit: 31-Dec-99 18:00     Last Update: 23-Sep-14 11:02 Refresh 1