Click here to Skip to main content
15,885,366 members
Articles / Mobile Apps
Tip/Trick

Mobile IMEI Validation

Rate me:
Please Sign up or sign in to vote.
4.92/5 (11 votes)
21 Dec 2011CPOL 60.2K   14   10
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.

C#
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionmy java implementation Pin
gemu16-Oct-13 10:24
gemu16-Oct-13 10:24 
GeneralReason for my vote of 5 Nice Tip/Trick Pin
thatraja26-Jan-12 22:23
professionalthatraja26-Jan-12 22:23 
GeneralRe: Thanks Raja --RA Pin
Rajesh Anuhya26-Jan-12 22:29
professionalRajesh Anuhya26-Jan-12 22:29 
GeneralReason for my vote of 5 helpfull Pin
User 75542058-Jan-12 3:29
User 75542058-Jan-12 3:29 
GeneralRe: Thanks m9gi Pin
Rajesh Anuhya19-Jan-12 0:14
professionalRajesh Anuhya19-Jan-12 0:14 
GeneralReason for my vote of 5 Nice tip to validate IMEI numbers me... Pin
Sridhar Patnayak2-Jan-12 6:28
professionalSridhar Patnayak2-Jan-12 6:28 
GeneralRe: Thanks Sridhar Pin
Rajesh Anuhya2-Jan-12 16:10
professionalRajesh Anuhya2-Jan-12 16:10 
GeneralGood work. Pin
Jipat26-Dec-11 17:48
Jipat26-Dec-11 17:48 
Generalgood work. I solved my problem for ur help. how can i checke... Pin
thileep201021-Dec-11 6:28
thileep201021-Dec-11 6:28 
GeneralGood one, nice to know how to validate IMEI numbers Pin
danlobo18-Dec-11 23:29
danlobo18-Dec-11 23:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.