The container number consists of four company codes and seven digits (such as cbhu3202732). The seventh digit is the verification code. First, convert the company code to a number, remove 11 and its multiples, and add and divide by 11. The remaining number is the check bit. A = 10 B = 12 C = 13 d = 14 E = 15 f = 16g = 17 h = 18 I = 19 J = 20 k = 21 L = 23 m = 24
N = 25 o = 26 p = 27 q = 28 r = 29 s = 30 t = 31 U = 32 V = 34 W = 35 x = 36 y = 37 z = 38
Basic concept of standard box number composition: adopts iso6346 (1995) standard. The standard container number consists of 11-digit codes, including three parts:
1. The first part consists of four English letters. The first three codes mainly indicate the owner and operator, and the fourth Code describes the container type. Standard containers starting with a column such as cbhu indicate that the owner and operator of the container are transported by COSCO.
2. The second part consists of six digits. Is the registration code, which is used as the unique identifier of a container. 3. The third part is the check digit code, which is calculated by the first four letters and six digits according to the verification rules to identify whether an error occurs during verification. It is a 11th-digit number. Each letter and number in the box number according to the validation rule has an operation value. The first 10 letters and numbers of the box number are 0 to Z, and the numbers are 0 to 38. The modulus of 11, 22, and 33 cannot be used for 11 ..
2. The corresponding value of the N-digit box number is multiplied by the (N-1) power of 2 (n =, 3 ........... 10)
For example, if the container number is cbhu3202732, its 1st-bit code is C,
Its code value = the power of the corresponding code value × 2 (1-1) = 13 × 1 = 13.
Similarly, the 2nd-bit code is B.
Its code value = the corresponding code value × 2 (2-1) power = 12 × 2 = 24 and so on to get the code value of the first 10 digits of the box number, after the product of the first 10 digits of the code value is accumulated, the code of the first 10 digits of the container whose model number is cbhu3202732 is accumulated as 4061, and 2 is after the model of the 11, it is the value of the 11th-bit identifier of the box number.
And so on, you can get the verification code.
// Determine whether the box number is correct
Private bool isright (string Daima, string Xianghao)
{
Try
{
// Obtain the calculated value of each code
String char1 = Daima. substring (0, 1 );
Int I1 = changevalue (char1 );
String char2 = Daima. substring (1, 1 );
Int I2 = changevalue (char2 );
String char3 = Daima. substring (2, 1 );
Int I3 = changevalue (char3 );
String char4 = Daima. substring (3, 1 );
Int I4 = changevalue (char4 );
// Obtain the calculated value of the 7-digit box number
Int int1 = int. parse (Xianghao. substring (0, 1 ));
Int int2 = int. parse (Xianghao. substring (1, 1 ));
Int int3 = int. parse (Xianghao. substring (2, 1 ));
Int int4 = int. parse (Xianghao. substring (3, 1 ));
Int int5 = int. parse (Xianghao. substring (4, 1 ));
Int int6 = int. parse (Xianghao. substring (5, 1 ));
Int int7 = int. parse (Xianghao. substring (6, 1 ));
// Calculate the sum of values and obtain the remainder for 11, and compare it with the seventh box number
Int sum = I1 + 2 * I2 + 4 * I3 + 8 * I4 + 16 * int1 + 32 * int2 + 64 * int3 + 128 * int4 + 256 * int5 + 512 * int6;
Int result = sum % 11;
If (result = int7 | result-int7 = 10)
{
Return true;
}
Else
{
Return false;
}
}
Catch (exception)
{
Return false;
Throw;
}
}
// Obtain the calculated value of the Code
Private int changevalue (string Str)
{
If (STR = "A") | (STR = ""))
Return 10;
Else if (STR = "B") | (STR = "B "))
Return 12;
Else if (STR = "C") | (STR = "C "))
Return 13;
Else if (STR = "D") | (STR = "D "))
Return 14;
Else if (STR = "e") | (STR = "e "))
Return 15;
Else if (STR = "F") | (STR = "F "))
Return 16;
Else if (STR = "G") | (STR = "G "))
Return 17;
Else if (STR = "H") | (STR = "H "))
Return 18;
Else if (STR = "I") | (STR = "I "))
Return 19;
Else if (STR = "J") | (STR = "J "))
Return 20;
Else if (STR = "K") | (STR = "K "))
Return 21;
Else if (STR = "L") | (STR = "L "))
Return 23;
Else if (STR = "M") | (STR = "M "))
Return 24;
Else if (STR = "N") | (STR = "N "))
Return 25;
Else if (STR = "O") | (STR = "O "))
Return 26;
Else if (STR = "p") | (STR = "p "))
Return 27;
Else if (STR = "Q") | (STR = "Q "))
Return 28;
Else if (STR = "R") | (STR = "R "))
Return 29;
Else if (STR = "S") | (STR = "S "))
Return 30;
Else if (STR = "T") | (STR = "T "))
Return 31;
Else if (STR = "U") | (STR = "U "))
Return 32;
Else if (STR = "v") | (STR = "v "))
Return 34;
Else if (STR = "W") | (STR = "W "))
Return 35;
Else if (STR = "X") | (STR = "X "))
Return 36;
Else if (STR = "Y") | (STR = "Y "))
Return 37;
Else if (STR = "Z") | (STR = "Z "))
Return 38;
Else
Return-1000;
}
Container number Verification Algorithm (C)