Method of verifying China's national identification number (in accordance with gb11643-1999 standard) (unknown source)

Source: Internet
Author: User

Method for verifying 18-bit ID number (GB11643-1999 compliant)
        /// <summary>         ///18-digit ID number verification/// </summary>         Private Static BOOLCheckIDCard18 (stringIdNumber) {            Longn =0; if(Long. TryParse (Idnumber.remove ( -), outN) = =false|| N < Math.pow (Ten, -) ||Long. TryParse (Idnumber.replace ('x','0'). Replace ('X','0'), outN) = =false)            {                return false;//Digital Verification            }            stringAddress ="11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91"; if(Address. IndexOf (Idnumber.remove (2)) == -1)            {                return false;//Province Verification            }            stringBirth = idnumber.substring (6,8). Insert (6,"-"). Insert (4,"-"); DateTime Time=NewDateTime (); if(Datetime.tryparse (Birth, outtime) = =false)            {                return false;//Birthday Verification            }            string[] Arrvarifycode = ("1,0,x,9,8,7,6,5,4,3,2"). Split (','); string[] Wi = ("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2"). Split (','); Char[] Ai = Idnumber.remove ( -).            ToCharArray (); intsum =0;  for(inti =0; I < -; i++) {sum+=int. Parse (Wi[i]) *int. Parse (Ai[i].            ToString ()); }            inty =-1; Math.divrem (SUM, One, outy); if(Arrvarifycode[y]! = idnumber.substring ( -,1). ToLower ()) {return false;//Check Code Verification            }            return true;//complies with gb11643-1999 standards}

Method of verifying China's national identification number (in accordance with gb11643-1999 standard) (unknown source)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.