By accident, I found the C # verification program in CSDN, So I adapted the JS version of the first edition. I believe it will be useful to everyone.
Algorithm source:
Generally, the second digit of the Vehicle identification code is the test digit, which can be expressed by any number or letter "X" in 0-9. The meanings of numbers and letters at other locations may be different. However, after the other 16-digit VIN code is determined, the ninth digit is obtained using the following method.
First, convert the letters in the other 16 digits into numbers according to the following relationship:
A = 1 B = 2 C = 3 D = 4 E = 5 F = 6G = 7 H = 8 J = 1 K = 2 L = 3 M = 4 N = 5 P = 7 R = 9 S = 2 T = 3 U = 4 V = 5 W = 6 X = 7 Y = 8 Z = 9
Each position has a weighted number:
Location: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Weights: 8 7 6 5 4 3 2 10*9 8 7 6 5 4 3 2
At last, multiply the weighting coefficient of each of the 16 bits outside the test bit by the corresponding value of this bits, and then add the product, divide the sum obtained by 11, the remainder is the value of the test bit. If the remainder is 10, the test digit is the letter "X ".
JS Code:
The Code is as follows: