2.5. Calculate the Check/Checksum Digit

Before a Code 128 symbol may be encoded, the software must compute the correct checksum digit which will be included in the bar code. The checksum digit is based on Modulus 103 Checksum based on the weighted sum of the values of each of the digits in the message that is being encoded, including the start character.

The steps for calculating the check digit are as follows:

  1. Take the value of the start character ("START A"=103, or "START B"=104, or "START C"=105) and make that the starting value of the running checksum.
  2. Starting with the first data character following the start character, take the value of the character (between 0 and 102, inclusive) multiply it by its character position (1) and add that to the running checksum.
  3. Take each additional character in the message, take its value, and multiply it by its character position, and add the total to the running checksum
  4. use the resulting to MOD 13, that is divide the resulting running checksum by 103, then the remainder is the checksum digit, which is added to the end of the message
  5. The stop character is appended after the checksum digit.

This is easier to understand with an example.

Let's calculate the checksum digit for the sample bar code above, "HI345678".

The checksum digit is included in all Code 128 bar codes, but it isn't printed as part of the text below the bar code symbol (as is the case with UPC and EAN symbols).

Table 2.1. Calculate checksum digit of "HI345678"

BarcodeSTART-AHICODE C345678
Character Value103404199345678
Character Position-123456
Calculation10340 * 141 * 299 * 334 * 456 * 578 * 6
Weighted Sum1034082297136280468


Summing up the running checksum for each digit, we get:

103 + 40 + 82 + 297 + 136 + 280 + 468 = 1406

Then,

1046 MOD 13 = the remainder of 1406 / 103 = 67

Thus the checksum digit is the character which has a value of 67.

[Note]Note
  1. Note that the checksum starts with the first Start Character, with a weight of 1, and that the first data character also has a weight of 1.
  2. In my understanding, the above "CODE-C=99" is the generated barcode, but not displayed/printed, just like the check digit.