At the time of registration on A Shanda website, the ID card is required, but I do not want to fill in the real ID card number, so I randomly compiled a string of ID card numbers that I think are legal, however, the system was immediately notified of a number error. Because of the extremely fast response speed, the online verification is not correct. That is to say, the second-generation ID card contains only a few rules that indicate birthday and gender, there are also other self-validation rules. So I opened the page source code and found that this section of js was not compressed, so the rules are quite understandable.
I am here to give you some tips. I don't know if it's Mars.
The following code is from here, and copyright belongs to Shanda. Of course, you can also find more detailed introductions and Algorithms in Wikipedia.
The Code is as follows:
IW = new Array );
ISum = 0;
For (I = 0; I <17; I ++ ){
IC = v_card.charAt (I );
IVal = parseInt (iC );
ISum + = iVal * iW [I];
}
IJYM = iSum % 11;
Var sJYM = '';
If (iJYM = 0) sJYM = "1 ";
Else if (iJYM = 1) sJYM = "0 ";
Else if (iJYM = 2) sJYM = "x ";
Else if (iJYM = 3) sJYM = "9 ";
Else if (iJYM = 4) sJYM = "8 ";
Else if (iJYM = 5) sJYM = "7 ";
Else if (iJYM = 6) sJYM = "6 ";
Else if (iJYM = 7) sJYM = "5 ";
Else if (iJYM = 8) sJYM = "4 ";
Else if (iJYM = 9) sJYM = "3 ";
Else if (iJYM = 10) sJYM = "2 ";
Var cCheck = v_card.charAt (17). toLowerCase ();
If (cCheck! = SJYM ){
Return false; // a false number is not displayed.
}