USPS Homepage Skip Navigation Home   |   Help   |   Sign In
  Find a ZIP Code   /   Calculate Postage   /   Print a Shipping Label   /   Schedule a Pickup   /   Locate a Post Office   /   Track & Confirm  
Main Navigation Bar Business Household Buy Stamps and Shop All Products and Services About USPS and News
 
Go to previous section of document Link to chapter contents   Go to next section of document

USPS Standards for Check Digit Computation

ACS participants using the keyline option must use one of the following algorithms to compute the check digit:

MOD 10

1. Consider the keyline as an ASCII string of 3 to 15 characters. Remove any spaces before beginning calculation.

2. Convert the remaining characters to pure numeric values by zeroing out all but the lower four bits. This yields the following values for each alpha character (numeric characters retain their value):

A = 1 E = 5 I = 9 M = 13 Q = 1 U = 5 Y = 9
B = 2 F = 6 J = 10 N = 14 R = 2 V = 6 Z = 10
C = 3 G = 7 K = 11 O = 15 S = 3 W = 7 blank
D = 4 H = 8 L = 12 P = 0 T = 4 X = 8 / = 15

3. Multiply the value at each odd-numbered position (first position, third position, fifth position, etc.) by a weighting factor of 2.

4. Add the digits (not the actual value) in all positions. For example, if the second position of the keyline is "L," whose value is 12, add the digits 1 + 2 (not the value 12) to the sum.

Note: The value of the letter "N" in an odd position, when weighted, becomes 14 x 2 = 28. The digits 2 and 8 are added, yielding 10. This sum is then further rendered as 1 + 0, not the integer 10.

5. Subtract the right-most digit of the sum from 10, yielding the check digit.

Note: If the right-most digit of the sum is 0, the check digit will be 0

Example 1. Computation of Check Digit for Keyline JLSTMS6796

Character J L S T M S 6 7 9 6
Position 1(O) 2(E) 3(O) 4(E) 5(O) 6(E) 7(O) 8(E) 9(O) 10(E)
Value 10 12 3 4 13 3 6 7 9 6
Weighted Value 20 12 6 4 26 3 12 7 18 6
Sum 2+0 +1+2 +6 +4 +2+6 +3 +1+2 +7 +1+8 +6 = 51

Right-most Digit of Sum: 1

Check Digit: 10-1=9

Complete Keyline: JLSTMS67969

Example 2. Computation of Check Digit for Keyline TMS1112/62

Character T M S 1 1 1 2 / 6 2
Position 1(O) 2(E) 3(O) 4(E) 5(O) 6(E) 7(O) 8(E) 9(O) 10(E)
Value 4 13 3 1 1 1 2 15 6 2
Weighted Value 8 13 6 1 2 1 4 15 12 2
Sum 8 +1+3 +6 +1 +2 +1 +4 +1+5 +1+2 +2 = 37

Right-most Digit of Sum: 7

Check Digit: 10-7=3

Complete Keyline: TMS1112/623

Example 3. Computation of Check Digit for Keyline 218XN91LMS

Character 2 1 8 X N 9 1 L M S
Position 1(O) 2(E) 3(O) 4(E) 5(O) 6(E) 7(O) 8(E) 9(O) 10(E)
Value 2 1 8 8 14 9 1 12 13 3
Weighted Value 4 1 16 8 28 9 2 12 26 3
Sum 4 +1 +1+6 +8 +1+0 +9 +2 +1+2 +2+6 +3 = 46

Right-most Digit of Sum: 6

Check Digit: 10-6 = 4

Complete Keyline: 218XN91LMS4

The following are additional examples of valid keylines that you may use for testing your algorithm. In each case, the check digit is the last character.

ABC999NN//32 OTUBIKALAM8
ANIT0281 SEIRAMT4
0012////8 14024981490
811NIS0001119 AEIOUW0
12345678907 DCS14020
09876543213 blank

Note: Although optional for COA information, keylines are required if the mailer wants to receive electronic ACS nixie notifications. Also, each keyline must end with a check digit correctly calculated using the Postal Service standard for check digit computation.

MOD 10 REVERSE

Computation of the MOD 10 Reverse is the same as the standard MOD 10 with one exception. MOD 10 Reverse is computed starting right to left instead of left to right.

MOD 21

ACS participants using the keyline option must use the following algorithm to compute the MOD 21 check digit:

1. Consider the keyline to be an ASCII string of 3 to 15 characters. Remove any spaces before beginning calculation.

2. Convert the remaining characters to pure numeric values using the conversion table below.

3. The positional value of a character is determined by multiplying the numerical value derived from the conversion table by one more than the length of the keyline without the check digit for the first character, the length of the keyline without the check digit for the second character, one less than the length of the keyline for the third character, and so on. Thus, for a keyline without a check digit of the minimum length of three characters, the numerical value of the first character would be multiplied by four and the numerical value of the second character would be multiplied by three. For a keyline without a check digit of the maximum length of 15 characters, the numerical value of the first character would be multiplied by 16, the numerical value of the second character multiplied by 15, the numerical value of the third character multiplied by 14, and so on up to multiplying the value of the 15th character by 2.

4. The positional values are added up. This total sum is divided by 21 and the remainder obtained. Multiply this number in whole number form (do not round up) by 21. Subtract the resulting product from the total sum. The difference is then subtracted from 21 yielding a numeric value, which should then be converted to the letter using the conversion table shown.

/ = 0 F = 6 L = 12 R = 18 X = 24 0 = 27
A = 1 G = 7 M = 13 S = 19 Y = 25 1 = 28
B = 2 H = 8 N = 14 T = 20 Z = 26 2 = 29
C = 3 I = 9 O = 15 U = 21 blank 3 = 30
D = 4 J = 10 P = 16 V = 22 blank 4 = 31
E = 5 K = 11 Q = 17 W = 23 blank 5 = 32
blank blank blank blank blank 6 = 33
blank blank blank blank blank 7 = 34
blank blank blank blank blank 8 = 35
blank blank blank blank blank 9 = 36

Example 1. Computation of Check Digit for Alphanumeric Keyline 025G

Character 0 2 5 G
Numeric Value 27 29 32 7
Multiply by 5 4 3 2
Positional Value 135 116 96 14
Total Sum of Positional Values 135+116+96+14 361
Total Sum Divided by 21 361/21 17.19
21 Multiplied by the Whole Number 21 x 17 357
Subtract Product From Total Sum 361 - 357 4
21 - Remainder 21 - 4 17
Check Digit 17 = Q Q
blank blank Complete Keyline: 025GQ

Example 2. Computation of Check Digit for Alpha Keyline QWERTY

Character Q W E R T Y
Numeric Value 17 23 5 18 20 25
Multiply by 7 6 5 4 3 2
Positional Value 119 138 25 72 60 50
Total Sum of Positional Values 119+138+25+72+60+50 464
Total Sum Divided by 21 464/21 22.10
21 Multiplied by the Whole Number 21 x 22 462
Subtract Product From Total Sum 464-462 2
21 - Remainder 21 - 2 19
Check Digit 19 = S S
blank blank Complete Keyline: QWERTYS

Example 3. Computation of Check Digit for Numeric Keyline 123456

Character 1 2 3 4 5 6
Numeric Value 28 29 30 31 32 33
Multiply by 7 6 5 4 3 2
Positional Value 196 174 150 124 96 66
Total Sum of Positional Values 196+174+150+124+96+66 806
Total Sum Divided by 21 806/21 38.38
21 Multiplied by the Whole Number 21 x 38 798
Subtract Product From Total Sum 806 - 798 8
21 - Remainder 21 - 8 13
Check Digit 13 = M M
blank blank Complete Keyline: 123456M
Go to previous section of document Link to chapter contents   Go to next section of document
 
       Site Map    Contact Us    Affiliates    Gov't Services    Jobs     |    National & Premier Accounts
Copyright © 1999-2007 USPS. All Rights Reserved.Terms of Use  Privacy Policy  No FEAR Act EEO Data
Postal Inspectors Web Page  Postal Inspectors
Preserving the Trust
Inspector General Web Page Inspector General
Promoting Integrity