Product Design, Manufacturing & Innovation Resources
Home » Product Design » Manufacturing » Checksums in Product Design and Manufacturing: How to Prevent Wrong Labels, Barcode Scan Errors, and Costly Recalls

Checksums in Product Design and Manufacturing: How to Prevent Wrong Labels, Barcode Scan Errors, and Costly Recalls

Checksums in Product Design and Manufacturing
Checksum
Implementing checksums enhances data integrity throughout the product lifecycle.

A pallet leaves the dock with the right product and the wrong label. The receiving plant scans it, the ERP accepts the code, and three weeks later a complaint traces back to a lot that nobody can locate. Nothing was wrong with the part. One digit was wrong in the data that identifies it.

A checksum is the cheapest control against this class of failure. It adds a few digits or bytes to a record, and any station downstream can verify the record without a database lookup.
Physical products carry data through many hands, machines and formats. A CAD file becomes a BOM, a BOM becomes a work order, and a work order becomes a label. The label becomes a scan, and the scan becomes a shipment record.

This guide treats the checksum as a quality tool, not an IT nor Dev topic. It covers the algorithms from check digits to SHA-256, then applies them stage by stage: design, industrialization, production, quality, logistics and service. Every chapter ends with two tips for engineers who work on physical products.

 

Table of Content
1. Why physical products depend on data integrity
2. What is a checksum?
3. Core properties and what they mean for quality metrics
4. A short history of checksums ans similar
5. Where checksums sit in the product lifecycle
6. Parity bits and simple sums
7. Check digits: how to calculate a GS1 check digit and why it matters
8. Barcode scan errors: causes, verification and fixes
9. How to prevent wrong labels
10. Network and fieldbus checksums
11. What is CRC error checking?
12. Non-cryptographic hash functions
13. Cryptographic hashes and how to verify a SHA-256 checksum
14. Keyed checksums, signatures and authenticity
15. Error-correcting codes
16. Comparison of algorithms
17. Design and engineering
18. Industrialization and manufacturing, including how to verify firmware flashing
19. Quality management and compliance
20. The Lean Six Sigma perspective
21. Logistics: how to reduce warehouse picking errors
22. Service, aftermarket and end of life
23. Accidental versus malicious corruption
24. How to choose the right checksum
25. Implementation guide
26. Best-practice checklist by role
Conclusion on Checksums and Similar
FAQ
Appendices

Note: regulatory dates in this article, such as those of the EU Cyber Resilience Act, the Digital Product Passport and the US DSCSA, were checked in November 2026. Confirm them again before you build a compliance plan on them.

Key takeaways

  • A checksum detects accidental error. Stopping deliberate change needs a signature or a keyed code.
  • Check digits protect identifiers that people and scanners handle. CRCs protect frames and firmware images. Cryptographic hashes protect files and records.
  • The GS1 check digit catches every single-digit error. It misses about 11 percent of adjacent transpositions, namely those where the two digits differ by 5.
  • Verify at the point of creation and again at the point of use. A single check at one stage leaves every other stage uncovered.
  • Treat the check itself as a measurement system. Challenge it with known-bad samples, calibrate verifiers, and track the results.

 

1. Why physical products depend on data integrity

A product is a physical object plus its data.

That data does include CAD models, drawings, bills of materials, firmware images, calibration tables, labels, batch records, test results and shipping documents. A wrong value in any of them can stop a line, send the wrong item to a customer, or force a recall.

Where data errors enter the chain

Errors typically come from these five sources:

  • People mistype digits or misread them.
  • Machines misread marks that are damaged.
  • Storage and transmission flip bits.
  • Process changes replace the right version with an obsolete one.
  • Finally, someone may alter data on purpose.
Data errors
Identifying sources of data errors in product design and engineering processes.
Error source Example Typical consequence Typical control
Keying Transposed digits in a part number Wrong component issued to the line Check digit
Reading Smudged 1D barcode decoded as another number Wrong lot recorded Symbology check, verification grade, error correction
Transmission Bit flip on a fieldbus frame Corrupted setpoint or sensor value CRC
Storage Degraded flash cell in the field Corrupted firmware or calibration data CRC, error-correcting code
Version Old label template left on a printer Obsolete data on shipped goods Hash of the released file
Tampering Modified firmware image Safety or security failure Signature, keyed code

 

Cost of poor quality

Cost of poor quality splits into prevention, appraisal, internal failure and external failure. A checksum works in the first two categories. It appraises data automatically and stops the error from travelling further. The saving comes from moving detection upstream.

An error caught at the label printer costs a reprint. The same error caught at the customer costs containment, sorting, possibly a recall, and lost trust.

Rules of thumb such as the 1-10-100 rule are illustrative at best. Your own scrap, rework and complaint records give the real multiplier.

Pro tips for engineers

  • Map every hand-off where a person re-keys data or a tool reformats it, from CAD release to shipping label. Place the first checks on those hand-offs.
  • Rank the hand-offs by your own escape history: complaints, scrap tags and rework records. Start where the cost per escaped error is highest, which is usually after the product leaves the plant.
Checksum
A checksum is a quick validation method for ensuring data integrity in product design and engineering.

2. What is a checksum?

A checksum is a small value computed from a block of data by a defined algorithm. The sender stores or transmits it together with the data. The receiver recomputes the value from what it received and compares the two. If they differ, the data changed somewhere between the two computations.

Think of a go/no-go gauge: you do not measure the full dimension of the data. You apply a fast, repeatable test that returns pass or fail.

 

Terminology of the checksum world

Several terms are used loosely in plants and in software teams. The table separates them by the question each one answers.

Term What it is Question it answers Typical use
Check digit One or two digits appended to an identifier, computed with a modular formula Was this number typed or scanned correctly? GTIN, SSCC, VIN, IBAN
Simple checksum Sum or XOR of the bytes of a message Did a short message arrive intact? NMEA 0183 sentences, Intel HEX records
CRC Remainder of a polynomial division over \(\mathrm{GF}(2)\) Did bits flip in this frame, block or image? CAN, Modbus RTU, Ethernet, firmware
Hash or digest Fixed-size fingerprint of arbitrary data Is this file identical to that file? Release packages, downloads, deduplication
MAC or HMAC Hash or cipher combined with a secret key Was this produced by someone holding the key? Authenticated messages, device tags
Digital signature Asymmetric proof of origin computed over a hash Who released this, and is it unchanged? Firmware, certificates, regulated records
Error-correcting code Redundancy that allows repair of damaged data Can the damage be repaired? DataMatrix, QR code, ECC memory

Detection versus correction

Most checksums only detect an error. They tell you that something is wrong and not what. That is enough on a production line, where the right reaction is to stop, reprint, rescan or retransmit. Error-correcting codes go further and repair the data, which suits marks that will be scuffed or memories that will degrade. Chapter 15 covers these codes in detail.

Pro Tips

  • Write a one-line specification for every check: the data it protects, the error model it assumes, the algorithm and its parameters. A check without an error model cannot be rated in an FMEA.
  • Store an algorithm identifier next to every stored check value, for example the name sha256 followed by the digest. A later migration then never invalidates archived records.

3. Core properties and what they mean for quality metrics

Each property of a checksum has a counterpart in the vocabulary of quality engineering. Mapping them lets you write the check into an FMEA or a control plan without translation.

Property Meaning Quality counterpart
Determinism Same input always gives the same value Repeatability of the check
Fixed output size The value has n bits whatever the input length Constant cost per check, known field length on the label
Detection probability Share of corrupted inputs that change the value \(1 – P_{\mathrm{escape}}\), input to the FMEA detection rating
Collision Two different inputs give one value Escape, also called false accept
Hamming distance Smallest number of bit errors that can go unnoticed Guaranteed detection depth
Burst length Longest run of corrupted bits always detected Fit with the real noise environment, for example EMI near drives
Avalanche effect In a good hash, one flipped input bit changes about half the output bits Makes an accidental match negligible

Detection probability in numbers

For an arbitrary corruption pattern, an \(n\)-bit check lets the error through with this probability:

\(\displaystyle P_{\mathrm{escape}} = 2^{-n}\)

A mod-10 check digit lets about one random error in ten through. A 16-bit CRC lets one in 65,536 (\(2^{-16}\)) through. A 32-bit CRC lets one in roughly 4.3 billion (\(2^{-32}\)) through.

Guaranteed properties are stronger than that statistical figure. A good CRC detects every single-bit error and every burst up to its own length. Engineers pick a specific polynomial for exactly this reason.

Escape rate arithmetic

The escape rate of a data error equals the probability that the error occurs, multiplied by the probability that the check misses it.

\(\displaystyle P_{\mathrm{escape}} = P_{\mathrm{error}} \times P_{\mathrm{miss}}\)

Take an error rate of 1 in 1,000 keyed entries and a mod-10 check digit. Then \(P_{\mathrm{escape}} = 10^{-3} \times 10^{-1} = 10^{-4}\). About 1 entry in 10,000 still passes with a wrong random value. State such numbers in the FMEA instead of rating detection by feel.

FMEA detection rating

In the AIAG-VDA FMEA handbook of 2019, detection controls are rated from 1 to 10, where 10 means no detection capability. The same handbook replaced the risk priority number with an action priority table that weighs severity first, then occurrence, then detection. An automated check that blocks the next operation can justify a much better detection rating than a visual check. Keep the evidence, for example a challenge test with known-bad samples.

False accept
Balancing error types in data validation to ensure accuracy and efficiency in product design.

False accept and false reject

Two error types apply to any check. A false accept lets bad data through, which is the escape. A false reject stops good data and costs line time. A correctly implemented check digit or CRC never rejects good data, because the rule is exact. False rejects come from the reading step, such as a scanner that fails on a valid but poorly printed code.

Tips

  • Cite the escape probability of an n-bit check for random corruption, and the guaranteed burst length and Hamming distance for structured faults, as detection evidence in the FMEA.
  • Do not multiply the escape rates of two checks unless their faults are independent. Two checks that read the same corrupted source, or share one operator or one software library, fail together.

4. A short history of checksums ans similar

The techniques in this article are old, and that is a strength. Each one has decades of field evidence behind it, and each failure mode is documented.

Year Development Why it matters here
Early 1950s Parity bits in telegraph and early computer storage First practical error detection
1954 Hans Peter Luhn of IBM files a patent on a check-digit method Origin of the mod-10 check on payment cards
1961 Peterson and Brown publish cyclic redundancy checks Basis of CRCs in buses and firmware
1969 Verhoeff publishes a decimal scheme that catches all adjacent transpositions Shows that better check digits exist than mod 10
1974 First UPC-marked item scanned at retail Start of barcode-based traceability
1995 SHA-1 specified in FIPS 180-1 Era of hash-based file verification begins
2002 SHA-2 family published in FIPS 180-2 SHA-256 becomes the default digest
2004 Damm publishes a quasigroup-based check digit Simple scheme with full transposition detection
2015 SHA-3 standardized in FIPS 202 Independent second family of hash functions
2017 First practical SHA-1 collision, known as SHAttered SHA-1 unsuitable wherever tampering matters
2022 NIST announces SHA-1 retirement by 31 December 2030 Planning horizon for long-life products

Pro tip: when you integrate a legacy interface, keep its original check on that link and add a stronger end-to-end check in the application layer. Changing the legacy frame format is rarely worth the risk.

5. Where checksums sit in the product lifecycle

Use this table as the map for the rest of the article. It shows which kind of check applies at each stage and where a failure would normally surface.

Stage Data at risk Typical protection Typical failure Where it surfaces
Design CAD, BOM, firmware source, part numbers Hash of released package, check digit in part number, CRC in firmware header Wrong revision released, mistyped part number Engineering change review, first build
Industrialization Recipes, PLC parameters, label templates, test programs Hash or CRC compare against a golden record Old recipe or template loaded First article, line trial
Production Marks, serial numbers, firmware, station data Verification grade, readback hash, bus CRC Unreadable mark, failed flash, corrupted frame In-line scan, end-of-line test
Quality Test records, certificates, genealogy Hash chain, signature, audit trail Altered or missing record Audit, customer complaint
Logistics GTIN, SSCC, GLN, ASN, EPCIS events GS1 check digit, message control totals Mis-pick, wrong ship-to, duplicate serial Pick confirmation, goods receipt
Service and end of life Updates, spare-part IDs, passports Signed updates, authenticated parts, unique identifiers Corrupted update, counterfeit part Field failure, warranty claim

Pro tips

  • Build a matrix of lifecycle stage, data object, check present and evidence kept. Each empty cell is a gap, and the matrix becomes your improvement backlog.
  • Generate the check at the source system and verify it at the receiving system with an independently written routine. Two implementations expose parameter and byte-order mistakes that one shared library hides.

6. Parity bits and simple sums

A parity bit is one extra bit that makes the count of ones in a word even or odd. It detects any odd number of flipped bits and misses every even number. Two flips cancel out and the word still passes.

Two-dimensional parity arranges data in rows and columns and adds a parity bit to each row and each column. It locates a single flipped bit and can therefore correct it. It detects all errors of two or three bits. Four flipped bits at the corners of a rectangle still escape.

Additive and XOR checksums

The next step up sums all bytes, or XORs them, and sends the result. These checks are cheap and fit on the smallest microcontroller. They share two weaknesses that matter in practice. They ignore byte order, so swapped bytes pass. Errors can also compensate: one byte rises by one while another falls by one, and the sum is unchanged.

An XOR checksum additionally misses any even number of flips in the same bit position across different bytes. Maxino and Koopman measured the effectiveness of such checksums for embedded control networks in 2009 and found that CRCs of the same width outperform them on structured errors.

Where they still appear

Place Scheme Comment
NMEA 0183 sentences (GPS, marine electronics) XOR of the characters between the dollar sign and the asterisk, sent as two hex digits Detects single-bit errors, weak against paired errors
Intel HEX records in firmware files Two’s complement of the sum of the record bytes Protects each record only, not the whole image
Legacy serial links and simple sensors 8-bit sum or XOR Read the datasheet, then add an application-level check if the data is critical

The Intel HEX case matters for firmware. A file can pass every record check and still be incomplete, because a missing record leaves no trace in the other records. Add an image-level CRC or hash, as chapter 18 describes.

Physical devices that still use parity and simple sums

Magnetic stripe cards

Each character carries an odd parity bit, and a longitudinal redundancy check character follows the end sentinel. A reader rejects a swipe that fails either test.

Serial instruments and PLC peripherals

RS-232 and RS-485 links can add a parity bit to every character, which catches single-bit flips caused by electrical noise.

Parity
Utilization of parity bits and checksums in physical devices for error detection and data integrity.

Flash programmers and bootloaders

They read Intel HEX and Motorola S-record files, which carry a sum for each record, and the tool normally rejects a record that does not match.


Expert Tips for IT

  • Never let an erased or zeroed block validate. Start the sum from a non-zero value or store its complement, so that a blank flash full of 0xFF or 0x00 bytes fails the check.
  • Sums and XOR ignore the order of bytes. If a legacy link forces one, add a length field and a sequence number, so that swapped, dropped or repeated frames are caught.

7. Check digits: how to calculate a GS1 check digit and why it matters

Check digits are the oldest and most widely deployed checksums in industry. They sit at the end of identifiers that people type and machines scan. They form the backbone of traceability, because every lot, serial number, location and shipment is referenced through an identifier.

How to calculate a GS1 check digit

GS1 requires a check digit on all fixed-length numeric identification keys, including GTIN-8, GTIN-12, GTIN-13, GTIN-14, GLN and SSCC. The algorithm is a weighted sum modulo 10. The weights alternate between 3 and 1, and the digit next to the check digit always gets the weight 3.

  1. Write the digits of the key without its check digit.
  2. Starting from the right, multiply the digits alternately by 3 and 1.
  3. Add up the products of all digits.
  4. The check digit is the amount that brings the sum up to the next multiple of 10. If the sum is already a multiple of 10, the check digit is 0.

Written as a formula, the check digit \(C\) uses the digits \(d_i\) of the body, counted from the right. The weight is \(w_i = 3\) for odd \(i\) and \(w_i = 1\) for even \(i\).

\(\displaystyle C = \left(10 – \left(\sum_{i=1}^{n} w_i d_i \bmod 10\right)\right) \bmod 10\)

Worked example for the GTIN-13 body 400638133393. Counted from the left, the weights are 1, 3, 1, 3 and so on, because the rightmost body digit is an odd position from the right.

Digit 4 0 0 6 3 8 1 3 3 3 9 3
Weight 1 3 1 3 1 3 1 3 1 3 1 3
Product 4 0 0 18 3 24 1 9 3 9 9 9

The products add up to 89. The next multiple of 10 is 90, so the check digit is \(C = (10 – (89 \bmod 10)) \bmod 10 = 1\) and the complete GTIN-13 is 4006381333931. The same rule applies to an SSCC. The 17-digit body 34012345000000001 sums to 43, which gives \(C = (10 – (43 \bmod 10)) \bmod 10 = 7\) and the SSCC 340123450000000017.

What a check digit catches

The table compares the GS1 scheme with three alternatives. The GS1 and Luhn figures were confirmed by simulation on random keys. The Verhoeff and Damm properties are documented in their original publications.

Error type GS1 mod 10 (weights 3 and 1) Luhn mod 10 Verhoeff Damm
Single-digit substitution All detected All detected All detected All detected
Adjacent transposition All except digit pairs that differ by 5, about 11 percent of swaps of different digits All except 09 and 90 All detected All detected
Random multi-digit garbage About 90 percent detected About 90 percent detected About 90 percent detected About 90 percent detected

The GS1 weighting is not the strongest scheme available. It is the one you must use for GS1 keys. For identifiers you define yourself, choose a stronger scheme.

A valid check digit also says nothing about existence. It shows that a number is well formed. It does not show that the GTIN is allocated, belongs to this product, or is active in your master data. Keep master-data validation in place next to the arithmetic check.

The VIN check digit in position 9

In North America, 49 CFR 565 requires a check digit in position 9 of the 17-character VIN. Each character is transliterated to a number and multiplied by a position weight: 8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2. The products are then summed. The remainder after division by 11 is the check digit, and a remainder of 10 is written as the letter X.

\(\displaystyle C = \left(\sum_{i=1}^{17} t_i w_i\right) \bmod 11\)

Here \(t_i\) is the transliterated value and \(w_i\) is the weight of position \(i\).

Many VINs of European origin do not carry a valid check digit, so a North American validation rule must not reject them automatically. A quick test for your own implementation: a VIN made of seventeen ones must produce the check digit 1. The text of the rule is in 49 CFR 565.15.

Other schemes you will meet

  • The EAN-13 barcodes on books carry an ISBN-13 and use the GS1 algorithm. The legacy ISBN-10 used a mod 11 scheme.
  • Payment card numbers and IMEI numbers use the Luhn algorithm, which Hans Peter Luhn of IBM described in a 1954 patent filing.
  • IBAN uses MOD 97-10 from ISO/IEC 7064.
  • Shipping container numbers under ISO 6346 end in a check digit.

Designing a check digit for internal part and serial numbers

Many plants invent identifiers and then add a homemade check. Homemade schemes often miss transpositions, which are a common keying error. Use a published scheme unless you have a documented reason not to.

  • Choose an established, published algorithm. Damm or Verhoeff suit numeric identifiers. ISO/IEC 7064 defines pure and hybrid systems for numeric, alphabetic and alphanumeric strings, among them MOD 11-2, MOD 37-2 and MOD 97-10.
  • Fix the length of the identifier and place the check character last.
  • Remove look-alike characters such as O and 0, or I and 1, from the alphabet, or handle them explicitly in the scheme.
  • Define the algorithm in a controlled document with test vectors, so that every system implements the same rule.
  • Test the scheme against the error classes you care about: single substitution, adjacent transposition, twin errors, and phonetic errors where voice entry exists.
  • Consider non-significant numbers for new schemes. They avoid renumbering when a classification changes.
  • Validate in every entry point, including ERP, MES, label software and PLC scripts. A check that exists in one system is bypassed by the others.

Devices and tools that validate check digits

Device or tool What it checks Why it helps
Barcode scanners and decoders The EAN or UPC check digit while decoding A misread is discarded and never reaches the host system
Label software and print servers The check digit of the key before the label prints A mistyped GTIN or SSCC never becomes a physical label
Payment terminals The Luhn digit of the card number Keying errors are rejected before any network call

Tips

  • Generate check digits from one tested library function and reuse it in every system. Never type a check digit by hand, and ship the test vectors of Appendix A below with the library.
  • Store identifiers as text with a fixed length, so that leading zeros survive in GTIN-14 and SSCC keys. Validate the check digit at every entry point: label print, receiving scan and ERP import.

8. Barcode scan errors: causes, verification and fixes

Barcode scan errors fall into three classes. A no-read stops the process and costs time. A misread returns a wrong value that looks valid. A wrong-read returns a valid value from the wrong item, for example from a neighbouring label. Misreads are the dangerous class, and the checks built into symbologies exist to keep them rare.

Checks built into the symbology

Symbology Built-in check Comment
EAN-13, UPC-A, ITF-14 GS1 mod 10 check digit Part of the encoded data
Code 128 and GS1-128 Mandatory mod 103 check character Protects the symbol, and the reader removes it. GS1 keys inside still carry their own mod 10 digit
Code 39 Optional mod 43 check character Enable it when you control both printer and reader
Interleaved 2 of 5 Optional mod 10 Fix the expected length in the reader to avoid partial reads
Data Matrix and QR code Reed-Solomon error correction Repairs damaged modules, see chapter 15

Reading is not the same as quality

A scanner that decodes a symbol does not prove that the symbol is good. Marginal symbols decode today and fail after the label scuffs in transit. A verifier measures print quality against a standard and assigns a grade.

Symbol type Grading standard Comment
Linear symbols on labels ISO/IEC 15416, edition 2025 Grades from 4.0 to 0.0, also written A to F
Two-dimensional symbols on labels ISO/IEC 15415, edition 2024 Grades A to F
Direct part marks (dot peen, laser, etching) ISO/IEC 29158, formerly the technical report ISO/IEC TR 29158 Uses different illumination. Its grades are not comparable with ISO/IEC 15415 grades

Verifiers need calibration with a conformance standard test card. The application standard or the customer defines the minimum acceptable grade. Check the current GS1 General Specifications and any sector rules for your symbol type.

Causes and fixes

Cause Symptom Fix
Low print contrast or unsuitable substrate Low grade, intermittent no-reads Change ribbon or substrate, adjust print darkness, verify at the printer
Quiet zone violated Misses at the label edge Correct the label layout, add a template check
X-dimension not matched to printer resolution Bars merge or gaps vanish Choose an X-dimension that is a whole number of printer dots
Reader configuration Misreads from enabled but unused symbologies Enable only the needed symbologies, fix lengths, validate the check digit
Glare or low modulation on direct marks Unstable reads Use illumination suited to the mark, verify to ISO/IEC 29158
Damage in transit Failure at the receiver Use 2D symbols with a higher correction level, protect the label with an overlaminate

Apply one rule at every scan station. Decode, validate the check digit, validate the format against the expected key, and only then accept the value. A scan that fails any step triggers a defined reaction. It must not trigger a retry loop that nobody counts.

Tips for real world applications

  • Put the minimum verified symbol grade into the labeling specification, with the measurement standard and the verifier setup. A symbol that scans on your line has shown only that it scans, not that it has margin.
  • Treat the quiet zone as a hard layout constraint in the label template. Test direct part marks to ISO/IEC 29158 under the lighting and reader angle of the real station.

9. How to prevent wrong labels

A wrong label is one of the most common and most visible data failures. It has several distinct causes, and a checksum addresses only some of them. Separate the causes before you choose the controls.

Failure mode Example Control Role of the checksum
Wrong data printed Order data changed after the print job was built Print from one released source, compare printed payload with the expected record Check digit validates the key, comparison catches the wrong key
Wrong template or version Obsolete layout with outdated regulatory text Release templates under document control and load them by hash Hash of the template file stored in the release record
Right label on the wrong product Roll change leaves labels of another product in the printer Line clearance, roll reconciliation, scan-to-match at application Check digit plus match against the expected GTIN or serial
Missing or misplaced label Label skipped by the applicator Presence detection, vision check None, a different control is needed
Duplicate serial number Reprint reuses a serial Central serial allocation, uniqueness constraint None, a check digit does not detect duplicates
Unreadable symbol Low-contrast print Inline verifier with a minimum grade Symbology check and grading

A closed-loop label process

  1. Release the label template and its data source under change control. Store a hash of the template file in the release record.
  2. At job start, the printer or label server computes the hash of the loaded template and compares it with the release record. A mismatch blocks the printing of the job.
  3. Build the payload from the single authoritative record. Generate the check digit in software with a tested library, and never type it by hand.
  4. Print, then verify the symbol inline. A grade below the specified minimum rejects the label.
  5. Scan the printed label and compare its decoded content with the expected record for this unit. Reject any unit whose label does not match.
  6. Scan again at the pack or ship station after application. The second check catches mix-ups that happen after printing.
  7. Reconcile the counts at the end of each run. Labels issued, applied, scrapped and returned must add up.

The sequence uses three kinds of checks. The hash proves the right template. The check digit and the format prove that the key is well formed. The comparison with the expected record proves that it is the right key for this unit. Only the third one catches a label that is well formed but wrong.

Tips

  • Run a line clearance before every label changeover. Remove old rolls, printed leftovers and the previous template, and let the print job start only after the template hash matches the release record.
  • Scan every printed label against the order record with a hard stop. Inject one known-bad label at the start of each shift to prove that the stop still works.

10. Network and fieldbus checksums

Machines protect their data with checks defined in the protocol. These checks guard the link, one hop at a time. They do not guard the data once it sits in PLC memory or in a database:

Internet checksums

IP headers, TCP and UDP use the 16-bit ones’ complement sum described in RFC 1071. It is cheap to compute and weak. It misses swapped 16-bit words and some compensating errors. Link layers add a stronger CRC underneath, which is why the weak checksum has survived.

Fletcher and Adler-32 are simple sums with two accumulators, so they catch more ordering errors than a plain sum. Adler-32 appears in the zlib library. It is weak on short messages.

Modbus RTU

Modbus RTU frames end with a 16-bit CRC. The polynomial is 0x8005, used in its reflected form 0xA001, with the initial value 0xFFFF. The low byte of the CRC is sent first. Modbus ASCII uses a simpler 8-bit longitudinal redundancy check instead.

Here is a complete RTU request that reads 10 holding registers from slave 1, starting at address 0. The CRC value is 0xCDC5, which goes on the wire as C5 followed by CD.

01 03 00 00 00 0A C5 CD

CAN and CAN FD

Classical CAN uses a 15-bit CRC with the polynomial 0x4599. It gives a Hamming distance of 6 for a fixed frame length, so any five randomly distributed bit errors are detected. CAN FD uses a 17-bit CRC for payloads up to 16 bytes and a 21-bit CRC above that, chosen to keep the same Hamming distance of 6.

Bit stuffing complicates the picture. CAN in Automation notes that stuffing can reduce the effective Hamming distance for some bit patterns in classical frames, and CAN FD adds a stuff-bit counter to close that gap. The details are in the CiA explanation of CRC in CAN frames.

Ethernet-based buses

PROFINET, EtherCAT, EtherNet/IP and Modbus TCP carry their data in standard Ethernet frames. Each frame ends with a 32-bit frame check sequence, a CRC-32, which devices check at every hop. Frames with a bad sequence are dropped.

Other buses, among them PROFIBUS and IO-Link, define their own frame checks. Read the protocol specification and record the check in your FMEA instead of assuming it.

Ethernet-based buses
Ethernet-based buses utilize standard ethernet frames with crc checks for reliable data transmission in industrial applications.

Safety protocols on top of the bus

Safety protocols such as PROFIsafe, CIP Safety and Fail Safe over EtherCAT treat the underlying bus as a black channel. The channel may corrupt, delay, repeat or reorder messages. The safety layer adds its own CRC, a sequence counter and a watchdog, so that the safety function does not depend on the checks of the link.

Take the lesson into your own designs. A link-level CRC does not protect a recipe while it sits in memory or travels through an OPC UA server and an MES. Add an end-to-end check at application level for every parameter set that affects safety or quality.

Tip: a gateway recomputes the CRC on the far side, so corruption inside its memory goes unseen. Add an end-to-end CRC with a counter across gateways for every safety-relevant signal and setpoint.

 

11. What is CRC error checking?

A cyclic redundancy check treats the message as a long binary number, which is a polynomial over \(\mathrm{GF}(2)\). It divides that polynomial by a fixed generator polynomial and keeps the remainder. The remainder is the CRC, usually 8, 16 or 32 bits long. The sender appends it, the receiver divides again, and any mismatch signals corruption.

A worked example

Take the 3-bit generator 1011, which stands for \(x^3 + x + 1\), and the message 1101. Append three zeros to get 1101000. Then divide by repeated XOR with the generator.

1101000
1011
-------
0110000
 1011
-------
0011100
  1011
-------
0001010
   1011
-------
0000001

The remainder is 001, so the transmitted word is 1101001. Dividing that word by 1011 gives the remainder 000. Flip any single bit and the remainder becomes nonzero. Real CRCs use generators of 8 to 32 bits and run in hardware or with lookup tables, but the principle is identical.

What a CRC guarantees

  • Every single-bit error, as long as the generator has more than one term.
  • Every burst error no longer than the CRC width.
  • Every odd number of bit errors, for generators that contain the factor \(x + 1\). The common 16-bit polynomials qualify. The Ethernet CRC-32 does not.
  • Longer bursts and random patterns pass with a probability of roughly \(2^{-n}\).
  • A Hamming distance that depends on the polynomial and on the message length.

The parameters that must match

Two parties compute the same CRC only if they agree on six parameters: width, polynomial, initial value, input reflection, output reflection and final XOR. Names such as CRC-16 or CRC-32 are ambiguous. The Reveng CRC catalogue lists the parameter sets in common use. Confirm an implementation with the check value of the ASCII string 123456789.

Variant Polynomial Init Reflect in and out Final XOR Check value Typical use
CRC-8 0x07 0x00 No 0x00 0xF4 Generic 8-bit checks, ATM header
CRC-8/MAXIM 0x31 0x00 Yes 0x00 0xA1 Dallas and Maxim 1-Wire devices
CRC-16/MODBUS 0x8005 0xFFFF Yes 0x0000 0x4B37 Modbus RTU
CRC-16/CCITT-FALSE 0x1021 0xFFFF No 0x0000 0x29B1 Serial protocols, bootloaders
CRC-16/XMODEM 0x1021 0x0000 No 0x0000 0x31C3 XMODEM, some bootloaders
CRC-32 0x04C11DB7 0xFFFFFFFF Yes 0xFFFFFFFF 0xCBF43926 Ethernet, ZIP, PNG
CRC-32C 0x1EDC6F41 0xFFFFFFFF Yes 0xFFFFFFFF 0xE3069283 iSCSI, storage, hardware instructions

Choosing a polynomial by message length

The strength of a CRC depends on the polynomial and on the message length. Koopman showed in a study of 32-bit CRCs that the IEEE 802.3 polynomial reaches a Hamming distance of only 4 on maximum-length Ethernet messages, while other polynomials reach 6. Embedded networks with short messages show wider gaps, and some widely copied 16-bit polynomials perform poorly at the lengths where they are used.

  • Fix the range of message lengths before you pick a polynomial.
  • Decide which Hamming distance you need at the maximum length. Safety-critical applications commonly require a distance of 6.
  • Take the polynomial from published exhaustive-search results, not from folklore or a code sample.

Limits of a CRC

A CRC is a linear function of the message. Given a message and its CRC, anyone can change the message and compute a matching CRC without a secret. A CRC therefore proves nothing about origin and cannot stop deliberate change. Chapters 13 and 14 cover the tools that can.

Devices that carry a CRC

Device Where the CRC sits Remark
UHF RFID tags (EPC Gen2) 16-bit CRC on tag replies Catches read errors at dock doors and conveyors
USB devices 5-bit CRC on token packets, 16-bit CRC on data packets The host retries a failed packet
SD and microSD cards 7-bit CRC on commands, 16-bit CRC on data blocks Common storage for logs and firmware in embedded products

Tip: make the CRC cover the header, address and length fields as well as the payload. A CRC over the payload alone lets a corrupted address or length through.

12. Non-cryptographic hash functions

Non-cryptographic hash functions such as xxHash, MurmurHash, CityHash and FNV trade security for speed. They run close to memory speed on modern CPUs and produce 32, 64 or 128 bit values that spread inputs evenly.

They offer no protection against someone who builds colliding inputs on purpose:

Where they help with product data

  • Detecting changed files during PLM and PDM synchronization, without transferring the files.
  • Deduplicating large test data sets and image archives from inspection systems.
  • Comparing a configuration export with a stored one to see whether anything changed.
  • Keying caches and lookup tables in MES and analytics pipelines.

Collision risk

The birthday bound sets the risk. For \(k\) items and a \(b\)-bit hash, the probability of at least one collision is approximately:

\(\displaystyle p \approx 1 – e^{-k^2 / 2^{b+1}}\)

With a 64-bit hash and one million distinct items, the probability that any two collide is about 2.7 in 100 million. With a 32-bit hash and 100,000 items, a collision is more likely than not, at roughly 69 percent.

Choose 64 bits or more for inventories. Treat a match as a strong hint, and confirm it by comparing the full data when the outcome matters. Never use these functions to prove that a file is authentic.

Tips for engineers

  • Use non-cryptographic hashes only for change detection and lookup inside your own systems. Keep 64 bits or more for inventories, and compare the full data whenever a match drives a decision.
  • Never store values from the built-in hash function of a programming language. Some, such as the string hash of Python, change between runs. Persist digests from a named algorithm with a fixed seed.
Sha-256
Understanding cryptographic hash functions and their resistance properties for secure product design.

13. Cryptographic hashes and how to verify a SHA-256 checksum

We are diving into technical practical details in this cghapter.

A cryptographic hash function must resist three attacks:

  • Preimage resistance means nobody can find an input for a given digest.
  • Second-preimage resistance means nobody can find a different input that matches the digest of a given input.
  • Collision resistance means nobody can find any two inputs with the same digest.
Algorithm Output Status Use
MD5 128 bits Collisions can be produced in practice Acceptable only for detecting accidental corruption. Avoid in new designs
SHA-1 160 bits Practical collision published in 2017. NIST plans to retire it by 31 December 2030 Legacy systems only
SHA-256, SHA-384, SHA-512 256, 384, 512 bits No practical attacks known Default for release hashes, firmware digests and signatures
SHA-3 (FIPS 202) 224 to 512 bits Different internal design from SHA-2 Alternative family where diversity is wanted
BLAKE2, BLAKE3 Up to 512 bits, 256 bits by default Modern and fast, not a FIPS-approved algorithm Large files where speed matters and approval is not required

NIST describes the SHA-1 retirement plan on its SHA-1 announcement page. A SHA-256 digest gives about 128 bits of collision resistance, which is far beyond any practical attack.

How to verify a SHA-256 checksum

You need two things: the expected digest from a trustworthy source, and the file. Compute the digest locally and compare the full string. Comparing only the first few characters throws away most of the protection.

# Linux
sha256sum firmware.bin
sha256sum -c SHA256SUMS

# macOS
shasum -a 256 firmware.bin

# Windows PowerShell
Get-FileHash .\firmware.bin -Algorithm SHA256

# Windows command prompt
certutil -hashfile firmware.bin SHA256

A SHA256SUMS file holds one line per file, with the digest, two spaces and the file name. The command sha256sum -c reads it and prints OK or FAILED for each file. Check any tool against the test vector in Appendix B before you rely on it.

A digest next to the file proves little

An attacker who can replace a file can replace the digest beside it. A published digest protects against a broken download. It does not protect against a hostile mirror or a compromised web server. For authenticity, use one of these routes.

  • Obtain the digest through a separate, trusted channel, for example the supplier portal over HTTPS or a signed purchase document.
  • Verify a digest file that is signed with a key whose fingerprint you obtained independently, for example with gpg –verify SHA256SUMS.asc SHA256SUMS.
  • Let the device or the installer check a code signature, so that no person has to compare strings.

Hash chains for batch records and audit trails

A hash chain makes a log tamper-evident. Each record stores the hash of the previous record, and its own hash covers its content plus that value.

\(\displaystyle H_n = \mathrm{SHA}\text{-}256(H_{n-1} \parallel r_n)\)

Here \(r_n\) is record number \(n\).

Change any record and every later hash stops matching. A chain proves order and integrity only if its latest hash is anchored outside the system that holds the log. Options are periodic signing, trusted timestamping under RFC 3161, or sending the hash to a customer or auditor. Without an anchor, anyone with write access can recompute the whole chain.

14. Keyed checksums, signatures and authenticity

Everything so far is public. Anyone can compute a CRC or a SHA-256 for a modified message. To stop deliberate change, the check must depend on a secret or on a private key.

Mechanism How it works Proves Key handling Typical use
HMAC (RFC 2104) Hash combined with a shared secret Message unchanged and made by a holder of the key Shared secret on both sides Authenticated messages between systems and devices
CMAC (NIST SP 800-38B) MAC built on a block cipher, usually AES Same as HMAC Shared secret, suits hardware with an AES engine Embedded devices, secure elements
AEAD tag (AES-GCM, ChaCha20-Poly1305) Encryption combined with an authentication tag Confidentiality, integrity and origin Shared key and a unique nonce per message Encrypted telemetry and updates
Digital signature (ECDSA, Ed25519, RSA) Private key signs a hash, public key verifies Integrity and origin, verifiable by anyone with the public key Private key in a hardware security module, public key in devices Firmware, certificates, regulated records

Shared-secret schemes put the key in every verifier. A key that sits in dozens of test stations or thousands of devices is hard to protect and hard to rotate. Signatures turn the problem around. Stations and devices hold only the public key, while the private key stays in a hardware security module at the release authority.

Do not build a MAC by hashing a secret followed by the message with SHA-256. SHA-2 allows length extension attacks on that construction. HMAC exists to avoid exactly this.

Secure boot
Secure boot and signed firmware enhance product integrity and security in engineering.

Use cases in product environments

    • Signed firmware and secure boot. The boot ROM verifies the bootloader signature, and the bootloader verifies the application. A CRC still has a place for runtime integrity of flash and RAM, but it never replaces the signature.
  • Spare part authenticity is a separate question. A serial number with a valid check digit proves nothing about authenticity, since anyone can compute it. Authentication needs a secret, for example a cryptographic tag in a secure element or a code that a server can verify and nobody can derive from the serial.
  • Labels can carry anti-counterfeiting data. GS1 defines an application identifier, AI 8030, for a digital signature carried in the data carrier alongside the key.
  • Regulated records need extra care. A cryptographic signature supports electronic records but does not equal an electronic signature under 21 CFR Part 11. The regulation also demands identity controls, the meaning of the signature and its link to the record.

Locks, keys and access devices

Mechanical and electronic locks show the difference between error detection and authentication.

  • Pin tumbler locks: the key cuts must match the pin heights, so the lock verifies a physical shape. The shape is effectively a shared secret, because anyone who copies it gains access.
  • Low-cost contactless credentials: read frames carry a CRC against radio errors, which proves nothing about identity. Older cards built on a broken proprietary cipher, such as MIFARE Classic, can be cloned. Modern credentials use challenge-response with standard ciphers such as AES.
  • Bluetooth Low Energy smart locks: the link layer protects each packet with AES-CCM, whose message integrity code is a keyed check.
  • Authenticated consumables and accessories: some printer cartridges, battery packs and sensors carry a chip that answers a cryptographic challenge from the host device.

Two pro-tips

  • Plan key management before choosing the algorithm. Use separate keys per product family, inject them at a secured station, keep them in a hardware security module, and log the injection per serial number.
  • Add a counter or nonce to every authenticated message. Without it, an attacker can replay a recorded valid message.

15. Error-correcting codes

Detection says that data is wrong, and correction repairs it. The price is more redundancy, and the benefit is that the process continues without a rescan, a retransmission or a rework step.

Code Principle Where you meet it
Hamming code with an extra parity bit (SECDED) Corrects any single-bit error and detects double-bit errors ECC memory in industrial PCs and microcontroller RAM and flash
Reed-Solomon Symbol-based correction that handles bursts well QR code, Data Matrix ECC 200, optical discs, storage systems
BCH Binary multi-bit correction NAND flash controllers
LDPC Iterative decoding close to the theoretical limit SSD controllers, wireless standards

Marks that survive damage

A QR code offers four correction levels, L, M, Q and H, which restore roughly 7, 15, 25 and 30 percent of the codewords. Data Matrix ECC 200 uses Reed-Solomon with a fixed amount of redundancy per symbol size. Laser-marked, dirty or scuffed parts benefit directly, and so do labels that travel through a supply chain.

Error correction makes a mark robust. It can also hide degradation. A damaged Data Matrix symbol may decode perfectly while its spare correction capacity shrinks toward zero. Verification under ISO/IEC 15415 reports the unused error correction as a graded parameter. Monitor the verifier grade, not the read result, to follow print and marking quality.

ECC memory and flash in embedded products

Microcontrollers for automotive and industrial use often protect flash and RAM with ECC. The hardware corrects single-bit flips and counts them. Read the corrected-error counters and log them. A rising count points to a degrading cell, a marginal supply or radiation upsets. A CRC computed after correction sees clean data, so the counter is the only early signal you get.

Ecc memory
Ecc memory enhances reliability in embedded products by detecting and correcting errors in flash and ram.

Devices and media that rely on error correction

  • Laser-marked and dot-peened parts carry Data Matrix ECC 200 symbols, which use Reed-Solomon codes, so a scuffed mark can still decode.
  • Servers, controllers and automotive microcontrollers: ECC memory typically corrects single-bit errors and detects double-bit errors.
  • SSDs, eMMC and SD cards: the controller applies BCH or LDPC codes to flash pages, and its corrected-bit counters can serve as a wear indicator.

Tips

  • Choose the error-correction level from the marking method and the environment. Test the choice with deliberate damage such as scuffing and partial masking, and grade the result.
  • Log the corrected-error counts of ECC memory, flash and symbol decoding. A rising trend is an early warning, because a unit that still works may have no correction capacity left.

16. Comparison of algorithms

The table summarizes the families and where each one fits in this article. Speed figures depend on the platform, so measure them on your own target hardware.

Algorithm Output size Detects Relative speed Security against deliberate change Typical use here
Parity bit 1 bit Odd number of flips Fastest None Legacy serial links
8-bit sum or XOR 8 bits Simple errors, weak on structured errors Very fast None NMEA sentences, Intel HEX records
GS1 mod 10 check digit 1 digit All single-digit errors, most transpositions Instant None GTIN, SSCC, GLN
Verhoeff, Damm 1 digit All single-digit errors and adjacent transpositions Instant None Internal identifiers
ISO/IEC 7064 family 1 or 2 characters Depends on the system Instant None IBAN, internal identifiers
CRC-16 16 bits Bursts up to 16 bits, Hamming distance set by polynomial and length Very fast, hardware support common None Modbus RTU, short frames
CRC-32, CRC-32C 32 bits Bursts up to 32 bits, Hamming distance set by polynomial and length Very fast, hardware instructions None Ethernet, firmware images, storage
xxHash64, xxHash128 64 or 128 bits Accidental differences Close to memory speed None Deduplication, change detection
SHA-256 256 bits Any change, for practical purposes Fast, hardware support on many CPUs About 128 bits of collision resistance Release hashes, firmware digests, audit trails
SHA-3-256, BLAKE2, BLAKE3 256 bits or more Any change, for practical purposes Fast Same class as SHA-256 Alternatives to SHA-256
HMAC-SHA-256, CMAC 128 to 256 bits Change and origin Fast Depends on key secrecy Authenticated messages
ECDSA, Ed25519 signature 64 bytes typical Change and origin Signing slower, verification fast Strong while the private key stays protected Firmware, records, certificates
Reed-Solomon Redundancy of roughly 10 to 30 percent of the data Detects and corrects Moderate None QR code, Data Matrix, storage

17. Design and engineering

Checksums enter the product before the first part is made. They belong in the release process and in the data model.

CAD, drawings and BOMs under release

A PLM or PDM system identifies a release by its revision. A revision letter says which version someone intended to release. A hash of the released package says which bytes were released. Store both in the release record. Any consumer can then verify what it received, which closes a gap that revision letters leave open: a file replaced or edited after release.

  • Compute a SHA-256 digest for each released file, for example the STEP model, the drawing PDF and the BOM export.
  • Compute one more digest over a manifest that lists all files and their digests, so a single value represents the whole package.
  • Put the manifest digest into the ECO or ECN record and into the transmittal sent to suppliers.
  • Let the supplier portal or the manufacturing system recompute and compare on receipt.
  • Compare BOM exports by hash between as-designed and as-built configurations. A mismatch flags a difference, and a people-driven review then explains it.

Error-proofing in part numbers and connectors

Design decides how easy it is to make a mistake later. A check digit on part numbers catches keying errors at every entry point. Distinct number formats for purchased parts, drawings and assemblies prevent one class from being mistaken for another. Keyed connectors and asymmetric label formats work in the same spirit on the physical side.

Embedded firmware and calibration data

A firmware image should be self-describing and self-checking. A common layout places a fixed header at a known address.

Header field Purpose
Magic number Identifies the image type and catches loading of the wrong file
Format version Lets the bootloader parse future header layouts
Product and hardware identifier Stops a valid image for another product from running
Software version Supports traceability and rollback protection
Image length Defines the region covered by the checks
CRC-32 of the image Detects accidental corruption at every boot or on demand
SHA-256 digest or signature Proves integrity and origin before first execution
Defined fill byte Keeps unused flash areas deterministic, so builds are reproducible

Apply the same discipline to calibration and configuration blocks in EEPROM or flash. Store a CRC with each block. Define what happens when the check fails: fall back to defaults, raise a fault, and never use the data silently. Keep a redundant copy and write blocks in a way that survives a power loss.

Functional safety context

Functional safety standards treat memory corruption and communication errors as failure modes that need diagnostic measures. ISO 26262 for road vehicles, IEC 61508 for industrial systems and IEC 62304 for medical device software all expect you to show how such faults are detected. Typical measures are CRCs over code and data memory, protected communication with sequence counters, and redundant storage.

The analysis must state diagnostic coverage, the share of failures that a measure detects. A 32-bit CRC does not automatically give 99 percent coverage for the whole system. Coverage depends on what the CRC covers, how often it runs, and what the system does when it fails.

Mechanical error-proofing built into hardware

Physical products used the idea of a check long before computers. In these designs the shape of the part is the check value.

Coded connectorsM12 connectors come with A, B, D and X coding, so a sensor cable does not mate with an Ethernet port. D-sub shells use a trapezoid shape for the same reason.Medical gas fittingsThe pin index safety system puts pins on the yoke at positions that differ for each gas, so a cylinder of the wrong gas does not fit.Small-bore medical connectorsThe ISO 80369 series defines connectors with distinct geometries for different applications, such as enteral and neuraxial, to prevent misconnections.Fuel nozzlesIn many markets a diesel nozzle is too large for a petrol filler neck.Locating pins and fixturesPins of different diameters in an asymmetric pattern let a part sit in one orientation only.Go and no-go gaugesA plug gauge passes a hole inside tolerance and rejects it otherwise. It is a physical pass or fail test, like comparing a checksum.

Pro tips on checksums in engineering

  • Prevent first and detect second. Use geometry, keyed connectors and asymmetric features as prevention controls in the design FMEA, and add the electronic identity check as a second layer.
  • Give every firmware and calibration image a header with version, length and CRC, and specify the behavior when the boot check fails. The safe state is a design decision and not a default.

18. Industrialization and manufacturing, including how to verify firmware flashing

Industrialization turns design data into running processes. Most data errors that reach production enter here: wrong recipes, wrong label templates, mismatched test limits.

Marking and scan-station error-proofing

  • Verify marks at the point of marking and again where the mark is first needed. ISO/IEC 15415, 15416 and 29158 define the grading.
  • Make the scan station a gate. The PLC releases the next operation only when decode, check digit, format and expected-value tests all pass.
  • Put check digits on serial numbers generated by the line, so that manual entry at rework stations is protected as well.
  • Record every failed scan with station, time and, where possible, the symbol image. This feeds the DMAIC work in chapter 20.

Recipes and parameters

Machine recipes, torque programs, welding schedules and test limits live as files or database rows. A mistaken or outdated parameter set creates a quiet defect, because the machine runs correctly with wrong instructions.

Keep a golden record in the MES or PLM together with its hash. At every recipe download and at the start of each lot, the station software recomputes the hash of the active recipe and compares it. A mismatch blocks production of the lot. For parameters sent over a bus to a controller, add a CRC inside the data block, so that the receiving controller does not run on corrupted values.

How to verify firmware flashing at end of line

Flashing is a process step like welding or torquing. It needs a defined method, an acceptance criterion and a record per serial number. A programmer that reports success has told you only that its commands completed.

  1. Program the image with the verify option of the programmer enabled, if the device and the tool support it.
  2. Read back the programmed regions and compute a SHA-256 or CRC-32 over exactly the regions defined in the control plan. Compare the result with the golden digest from the release record.
  3. Handle unit-specific data in a separate step. Serial number, MAC address and calibration values differ per unit. Exclude them from the whole-image digest and verify them against their own records, or compute the expected digest with the unit data patched in.
  4. Verify option bytes, fuses and lock bits. A correct application with the wrong boot configuration or without readout protection is a defective unit.
  5. Ask the running device for its software version and for the digest of its own image over the application protocol. Many products compute a CRC of their flash with a hardware peripheral and report it. This also tests the communication path.
  6. Write the result to the MES against the unit serial number, together with the image digest and the tool version. Do not let the unit move on without a pass record.
  7. Challenge the station at defined intervals with a known-bad sample, for example an image with one flipped bit. This proves that the station still rejects.
Method Strength Time cost Limits
Programmer verify Compares flash with the source image just written Low Does not cover option bytes, depends on the tool implementation
Readback and hash on the station Independent check of the actual contents Medium to high for large images, since readback is often slower than programming Needs readback to be allowed, which readout protection may forbid
Device-computed CRC reported over the bus Fast, and tests the application path Low Protects against accidental error only, and relies on the firmware that computes it
Signature check by the bootloader on first start Proves integrity and origin Low Accepts a wrong but validly signed image, so combine it with a version check

Mind the order of the steps: once you enable readout protection, a later readback is impossible. Verify first, then lock, then check that the lock bit is set.

Test-station and tool records

Torque, vision, leak and electrical test results are commercial and sometimes legal evidence. Records stored as plain files or rows can be altered or lost without a trace.

  • Compute a record hash over serial number, station, time, result and measured values.
  • Write records to an append-only store, or chain them as described in chapter 13, with periodic anchoring.
  • Synchronize station clocks with a trusted time source, so that timestamps mean something.

Machine-to-machine communication

OPC UA offers message signing and encryption through its security modes Sign and SignAndEncrypt. Use them between stations, PLCs and the MES. Transport security protects the data in motion. It does not replace application-level checks on critical parameters, which must survive storage, conversion and export.

Station devices that error-proof the process

Some physical measures act like a checksum. The weight of a kit, for example, is a redundant property that must match the expected value.

Device What it verifies Typical hard stop
Fixed-mount scanner or vision reader Decoded label or mark content against the work order PLC interlock that holds the conveyor
Torque and angle controller with fixture identification The right program for the right joint, and torque and angle inside the window Tool disabled until the correct program is active
Checkweigher Mass of the assembly or kit against the expected mass Reject gate for a missing or extra part
Part-presence sensors and keyed fixtures Presence, type and orientation of the part Cycle start not released
Programming fixture with read-back Digest of the programmed region read from the device itself Unit marked as failed and routed to repair
Go and no-go or air gauge Dimension inside tolerance Part segregated automatically or by the operator
Image verification
Implement secure image verification for product updates.

Pro tips

  • Let the station load an image only by revision from the release server, and verify its hash or signature before flashing. Refuse any image that does not match the work order.
  • Put every bypass of a hard stop behind a key switch or an authorized login, and trend the bypass count per line and shift. A rising count shows a weak control before an escape does.

19. Quality management and compliance

Quality systems ask for outcomes that checksums help to deliver: identification, traceability, controlled documents and trustworthy records. The standards rarely name checksums. They name outcomes, and a check is one way to prove an outcome.

Framework Relevant requirement How a checksum supports it
ISO 9001:2015 Clause 8.5.2 on identification and traceability, and the control of documented information Check digits on identifiers, hashes of controlled documents
IATF 16949 Traceability, error-proofing, control plans, PPAP Poka-yoke with check digits and verification, hashes in PPAP data packages
AS9100 Configuration management, product identification, prevention of counterfeit parts Release hashes for configuration baselines, authentication of parts
ISO 13485:2016 Traceability (clause 7.5.9), UDI, software validation UDI check digits, validated verification of labels and firmware
21 CFR Part 11 and EU Annex 11 Electronic records, audit trails, electronic signatures Hash chain over the audit trail, signature of records
GAMP 5 Risk-based validation of computerized systems Validation of the checking function itself

Data integrity and ALCOA+

Regulators describe data integrity with the ALCOA principles: attributable, legible, contemporaneous, original and accurate. The extended ALCOA+ adds complete, consistent, enduring and available. A checksum maps to a few of these. It shows that a record is accurate and unchanged since it was created. A hash chain shows that records are complete and in order.

A checksum does not show who created a record or when. It complements the audit trail and access control and does not replace them.

Traceability and recall readiness

Traceability relies on identifiers that stay correct from component receipt to shipment. Check digits keep identifiers correct as they pass through scanners and keyboards. Genealogy links lot, batch and serial numbers across levels, one step up and one step down.

Measure readiness with a mock recall. The metric is the time from a trigger, for example a supplier lot number, to the full list of affected finished units and their locations. Failed checks and duplicate identifiers are typical reasons why a mock recall takes days instead of hours.

Calibration
Implement robust verification processes for calibration and supplier data in product design and engineering.

Calibration, test equipment and supplier data

  • Tie calibration certificates to equipment identifiers that carry a check digit, and keep a hash of each certificate file.
  • For supplier certificates such as CoC, CoA and material test reports, ask for signed files or structured data. Compare lot number and part number automatically against the purchase order and the receiving record.
  • For supplier CAD files, firmware and test programs, verify the digest against the transmittal before anyone uses the file.

Bonus: validating the check itself

In regulated settings the checking function is part of a computerized system and needs validation under GAMP 5 principles. Plan installation, operational and performance qualification (IQ, OQ and PQ) in proportion to risk.

The OQ must include negative tests. Feed the check bad data and prove that it rejects. Keep the test vectors in the validation file and rerun them after any change to software, reader firmware or label templates.

Tip: validate the check as part of the process. Include negative tests, store the test vectors in the validation file, and rerun them after any change of scanner firmware, printer, library or operating system.

20. The Lean Six Sigma perspective

Poka-yoke
Integrating poka-yoke and jidoka enhances product design by ensuring built-in quality and error prevention in engineering processes.

Poka-yoke and jidoka

Many commonalities with checksums: Shigeo Shingo formalized poka-yoke, or mistake-proofing, while working with Toyota. He separated control functions, which make the error impossible or stop the process, from warning functions, which only signal it. Jidoka, built-in quality, adds the stop: the machine halts when it detects an abnormality.

A check digit with a hard stop at a scan station is a control function. A scan failure that lets the unit pass anyway is only a warning. Audit your stations for exactly this difference.

FMEA

Rate the detection of each control honestly. A check with a hard stop, tested with known-bad samples and covering the failure cause, earns a better rating than the same check that operators can bypass. Record the evidence in the PFMEA.

The AIAG-VDA action priority method also pushes you to improve prevention first. Prevention here means designing the process so that the wrong data cannot arise, for example by generating identifiers and labels from one source instead of typing them.

DMAIC applied to data errors

Phase Activity Example with mislabeled products
Define Problem, scope, critical-to-quality characteristic Wrong labels reached customer A in the last 12 months. The CTQ is that label content matches the product in 100 percent of units
Measure Baseline and measurement system Count defects per million labels, and run an attribute agreement analysis of the verifier against a reference
Analyze Root causes Pareto chart of causes: template version, roll changes, manual entry, reprints
Improve Controls Template hash check, scan-to-match, central serial service, check digits wherever keying remains
Control Sustain the gain Control chart of scan failure rate, control plan, audits, reaction plan

The defects per million opportunities follow from the number of defects \(D\), the units \(N\) and the opportunities per unit \(O\). The sigma level adds the conventional 1.5 sigma shift to the normal quantile.

\(\displaystyle \mathrm{DPMO} = \frac{D}{N \times O} \times 10^{6}\) \(\displaystyle \sigma_{\mathrm{level}} = \Phi^{-1}\left(1 – \frac{\mathrm{DPMO}}{10^{6}}\right) + 1.5\)

A worked example with illustrative numbers shows the arithmetic. 36 wrong-label defects in 480,000 labels, counting one opportunity per label, give \(\mathrm{DPMO} = 36 / 480000 \times 10^{6} = 75\). With the conventional 1.5 sigma shift, that is a sigma level of about 5.3. After the improvements, 6 defects in the next 480,000 labels give 12.5 per million and about 5.7 sigma. The figures illustrate the calculation. They are not a benchmark.

Measurement system analysis and SPC

Treat scanners and verifiers as measurement systems. Verifiers need calibration traceable to a conformance standard. For pass or fail data, run an attribute agreement analysis between operators, scanners and a reference, to quantify agreement and bias.

Then monitor with control charts. A p-chart suits the proportion of failed scans per lot. A u-chart suits defects per unit. A rising first-read failure rate often signals printhead wear, ribbon wear or a changed substrate long before verification grades fall below the limit.

Waste and return on investment

Data errors create classic wastes: defects, rework, waiting for corrected data, motion to find the right item, and excess inventory held as a buffer against bad data. A simple model sums, over all stages \(s\), the number of errors \(n_s\) times the cost per error \(c_s\).

\(\displaystyle C_{\mathrm{total}} = \sum_{s} n_s c_s\)

Compare that figure with the cost of implementation, which is mostly software configuration, scanner and verifier hardware, and training.

Take the cost per error from your own cost accounting. It differs by a large factor between an error caught at the printer and an error caught at the customer.

Control plan example

Characteristic Method Frequency Acceptance Reaction plan
Label template identity Hash compared with the release record Every job start Match Block the job, notify engineering
Symbol print quality Inline verifier 100 percent, or a sample per lot if the risk allows Grade at or above the specified minimum Reject the label, check printhead and ribbon
Label content against unit record Scan and compare 100 percent Exact match Segregate the unit, investigate roll and data
Firmware digest Readback hash 100 percent at end of line Match with golden digest Reflash once, then scrap and find the root cause
Health of the check function Known-bad challenge Each shift Rejection is recorded Stop the line, recalibrate or repair
Traceability Mock recall from lot to units Annually or per audit plan Target time met Close gaps in genealogy data

Three families of poka-yoke devices

Shingo grouped mistake-proofing methods into three families. Each has a counterpart among the checks in this guide:

Contact method
Detects shape, size or color by touch or by a sensor, for example a limit switch or a keyed fixture. The data counterpart is a format or check digit test.
Fixed-value method
Signals an error when a set number of parts or motions is not reached, for example a tray with counted positions. The data counterpart is a length field or a segment count.
Motion-step method
Checks that the steps happen in the right sequence, for example an interlock that blocks a step until the previous one is complete. The data counterpart is a sequence number or a scan-to-release workflow.

Tips

  • Feed the reject data of the check stations into SPC, for example a u chart per line, with subgroups by shift, printer or fixture. A stable reject rate can still hide a rework loop that costs capacity.
  • Count a rejection at the check as a defect of the previous process step and not as a success of the check. Assign the cause and close the loop at the source.

21. Logistics: how to reduce warehouse picking errors

Picking errors are among the costliest data-driven failures in logistics. Each one starts a chain of returns, reshipments and complaints.

GS1 identification

The GTIN identifies a product at a given packaging level. The SSCC identifies a logistics unit such as a pallet and has 18 digits. The GLN identifies a location or a party. The GRAI identifies returnable assets. All carry a check digit, and the GS1 logistic label standard defines how they appear on units.

Scan-based error-proofing

  1. Scan the label of the location first. Check digit and format validation catch a bad location code at once, and the WMS confirms that it is the expected location.
  2. Scan the item or case GTIN. The system compares it with the pick task and rejects a wrong item before quantity entry.
  3. Confirm the quantity by scan count, or by weight check where scanning every piece is impractical.
  4. Scan the destination container or SSCC when closing the unit, and link the contents to it.
  5. At loading, scan the SSCCs against the shipment manifest.
Cause of picking error Typical remedy
Similar-looking items in adjacent slots Scan-to-confirm on the GTIN, slotting rules
Manual keying of location or item codes Remove the keyboard from the process, and use check digits where keying is unavoidable
Confusion of unit of measure (each, inner pack, case) Distinct GTINs per packaging level, using the GTIN-14 indicator digit
Damaged or unreadable labels Verification at labeling, 2D codes with error correction, a relabel station
Master data errors Validate GTIN check digits at import and compare with the supplier’s source data
Duplicate SSCC Central allocation and a uniqueness constraint

Quantify accuracy as defects per million lines picked. A line accuracy of 99.9 percent sounds high, yet it equals \((1 – 0.999) \times 10^{6} = 1000\) errors per million lines, far from six sigma. State targets in DPMO, so that they connect to your Lean Six Sigma metrics.

EDI, ASN and EPCIS message integrity

Business messages carry integrity fields of their own. EDI standards include control numbers and segment counts, for example in the closing segments of an EDIFACT message or an X12 transaction set. The receiver uses them to detect truncated or lost data. EPCIS events carry the identifiers of the units involved, and the value of the event depends on the check digits and the uniqueness of those identifiers.

Validate at message receipt in this order: control counts, identifier check digits and formats, and then business rules such as an ASN matching the purchase order. Reject or quarantine failing messages, and track the rejection rate by trading partner.

Serialization in regulated chains

Pharmaceutical and medical device chains add serialization rules. In the United States, the Drug Supply Chain Security Act requires a product identifier with NDC, serial number, lot and expiry in a 2D Data Matrix on each package. The enhanced distribution security requirements took effect in stages. The original date was 27 November 2023, a stabilization period ended on 27 November 2024, and the FDA granted small dispensers exemptions until 27 November 2026 (FDA exemption notice).

Law firm summaries report that the FDA extended certain small-dispenser exemptions to 27 November 2027 in August 2026 (Buchanan summary). Check the FDA website for the current status.

In the EU, the Falsified Medicines Directive framework places a unique identifier and an anti-tampering device on packs. Medical device UDI follows the same logic. Issuing agencies such as GS1 define the identifier structure, and the check digit validates it.

Cold chain and IoT data

Temperature loggers and IoT sensors produce the evidence that a shipment stayed within limits. Choose devices that store readings with a CRC or a signature, and prefer signed downloads. Protect transport with authenticated encryption. Without these steps, a log file is an editable spreadsheet.

Anti-counterfeiting and track-and-trace

A serial number with a valid check digit is easy to forge. Track-and-trace adds a server-side record of which serial numbers were issued and where they were seen. A repeated serial at two locations, or a serial that was never issued, is the signal. For high-value goods, add a signature or a secure element, as chapter 14 describes.

Blockchain and distributed ledgers

Distributed ledgers can anchor the hashes of supply chain events, so that nobody can quietly change history. They do not verify that an event really happened, or that the scanned item was the genuine item. Wrong data stays wrong, now with a permanent timestamp.

A signed hash chain with external anchoring provides the tamper evidence that most plants need, without the operational overhead. Consider a shared ledger only when several parties who do not trust each other need one common record.

 

Examples of Warehouse devices and tools

  • Voice picking headsets: the system asks the picker to speak the check digits posted at the pick location. A wrong location is rejected before any item is picked.
  • Pick-to-light and put-to-light modules: a light and a quantity display mark the bin, and the operator confirms with a button. Add an item scan where mis-picks are costly.
  • Hand-held and ring scanners: scan-to-confirm of the location, the item and the SSCC of the pallet label.
  • Weighing and dimensioning stations: measured weight is compared with master data, so a wrong item or a damaged carton is flagged.
  • RFID portals at dock doors: tags read inside a pallet are compared with the advance shipping notice.

22. Service, aftermarket and end of life

Over-the-air updates
Robust update processes in product design ensure security and reliability through layered defenses against potential failures.

Over-the-air and field updates

An update process can fail in three ways. The transfer is corrupted, the image is wrong for the device, or the image is malicious. Layer the defences to match those failures.

  • A CRC per chunk or per block catches transfer errors early.
  • A hash of the whole image, checked before installation, confirms completeness.
  • A signature check against a public key stored in the device confirms origin.
  • A match of product and hardware identifier prevents installing an image meant for another device.
  • A version check with rollback protection prevents downgrades to vulnerable releases.
  • Dual partitions with a boot-time confirmation leave the old image runnable if the new one fails.

Spare parts, warranty and returns

  • Spare part numbers carry a check digit, and web forms for warranty registration validate it, which exposes keying errors at the source.
  • Serial numbers link a field failure to the production genealogy, including the firmware digest recorded at end of line.
  • Reverse logistics needs the same identifiers and the same checks as the forward flow.

Digital Product Passport

The Ecodesign for Sustainable Products Regulation, (EU) 2024/1781, entered into force on 18 July 2024 and introduced the Digital Product Passport: a passport links standardized lifecycle data to a data carrier on the product, often a QR code.

The European Commission launched the DPP registry with a test environment on 20 July 2026. The first mandatory passport applies to certain batteries from 18 February 2027 under the EU Batteries Regulation. Other product groups follow as delegated acts are adopted. See the Commission page on batteries and the registry announcement.

The consequences for data integrity are direct. The unique product identifier must stay unique, persistent and correct over the whole life of the product, which justifies a check digit and a central allocation process. Passport data should be verifiable, which points to hashes of the underlying documents and signatures from the economic operator. The data carrier must also stay readable, which brings you back to marking quality and error correction.

23. Accidental versus malicious corruption

The right check depends on who or what causes the error. Noise, wear and human slips are random. An attacker or a counterfeiter is not, and chooses the one modification that your check cannot see.

Threat Example Checks that help Checks that do not help
Accidental error Bit flip, mis-keyed digit, partial download Check digit, CRC, hash None needed beyond these
Deliberate modification Edited firmware, altered test record Signature, HMAC CRC, plain hash, check digit
Substitution Counterfeit part with a copied serial number Authentication tag, track-and-trace Check digit
Replay Valid old message sent again Sequence counter or timestamp covered by a MAC Any static checksum
Rollback Old signed but vulnerable firmware reinstalled Version check with anti-rollback counter Signature alone

Collision attacks matter wherever two parties trust a digest over a file that one of them prepared. MD5 and SHA-1 fail this test. For message authentication, use HMAC and never a secret-prefix hash, because of length extension.

Industrial cybersecurity and regulation

The IEC 62443 series defines a foundational requirement on system integrity. It covers communication integrity and the integrity of software and information in industrial automation and control systems. Checks on firmware, configuration and recipes are direct evidence for it.

The EU Cyber Resilience Act, Regulation (EU) 2024/2847, entered into force on 10 December 2024. Reporting obligations for actively exploited vulnerabilities and severe incidents have applied since 11 September 2026, including to products already on the market. The first notification is due within 24 hours of the manufacturer becoming aware. Full application, with essential requirements and CE marking, starts on 11 December 2027. Fines for breaches of the reporting obligations can reach 15 million euros or 2.5 percent of worldwide annual turnover. A summary by Matheson covers the timeline.

The essential requirements include protection of the integrity of data, programs and configuration against unauthorized modification, and secure update mechanisms. Signed firmware and verified updates therefore become a compliance matter and not only an engineering preference. The NIS2 Directive, (EU) 2022/2555, adds security and reporting duties for many manufacturers of machinery, electrical equipment, vehicles and medical devices.

Counterfeits, grey market and supply-chain attacks

  • Counterfeit goods copy labels and serial numbers. The defence is authentication with a secret, not a better check digit.
  • Grey-market goods are genuine but diverted. Track-and-trace rules that flag a serial number seen in the wrong region expose them.
  • Supply-chain attacks target the build server, the update channel or component firmware from suppliers. Use signed builds, keep a software bill of materials with digests, and verify supplier firmware digests through a second channel.

24. How to choose the right checksum

Start with the threat, then the data type, then the constraints. Work through the questions in order and stop at the first mechanism that fits, then add the next one if the answer to a later question is also yes.

  1. Could someone change the data deliberately and benefit from it? If yes, use a digital signature or an HMAC. Keep a CRC or hash only for accidental errors.
  2. Does a person type, read or scan the value? If yes, use a check digit on the identifier, validation at the scanner, and 2D marks with error correction against physical damage.
  3. Does the data travel over a bus or sit in small memory? If yes, use a CRC with a polynomial chosen for the message length and the Hamming distance you need. Add an end-to-end CRC for critical parameters.
  4. Must a file or record be shown identical to a reference? If yes, use SHA-256 for the comparison. A fast non-cryptographic hash is enough for non-critical comparisons.
  5. Must the data survive damage without a retry? If yes, add an error-correcting code.
  6. Is the data part of a regulated record? If yes, add an audit trail, validation, and a documented rationale for the chosen method.
Data or stage Risk Recommended approach
Part numbers and serials typed by people Medium Damm, Verhoeff or ISO/IEC 7064 check digit. GS1 digit for GS1 keys
Labels and marks Medium to high Verification to ISO/IEC 15415, 15416 or 29158, 2D symbols with error correction, template hash
Fieldbus and sensor data Medium Protocol CRC with a Hamming distance that fits the length, safety protocol where required
Recipes and parameters High Hash against the golden record, plus a CRC in the transfer block
CAD and release packages Medium SHA-256 manifest stored in the release record
Firmware and updates High Signature and SHA-256 for release, CRC for runtime checks
Regulated records High Hash chain or signature with an audit trail, validated
Logistics identifiers and messages Medium GS1 check digits, message control totals, business-rule validation
Bulk comparison and deduplication Low xxHash with a full comparison on match

Tips for decision

  • Keep a decision record for each data object: error model, carrier, size budget, lifetime and owner. Review it at every design gate and whenever the supply chain or the threat changes.
  • Test candidate checks with injected errors that match real failure modes: bit flips, transposed digits, truncation and the wrong file. Measure the detection rate instead of relying on theory.

25. Implementation guide

Three rules save most of the pain. Use a tested library or a single shared implementation. Fix every parameter in a controlled document. Test with published vectors before the first production run. Appendix B holds the vectors used below.

GS1 check digit in Python

def gs1_check_digit(body: str) -> int:
    if not body.isdigit():
        raise ValueError('digits only')
    total = sum(int(d) * (3 if i % 2 == 0 else 1)
                for i, d in enumerate(reversed(body)))
    return (10 - total % 10) % 10

def gs1_is_valid(full: str) -> bool:
    return (full.isdigit() and len(full) > 1
            and gs1_check_digit(full[:-1]) == int(full[-1]))

assert gs1_check_digit('400638133393') == 1
assert gs1_check_digit('34012345000000001') == 7
assert gs1_is_valid('4006381333931')

GS1 check digit in Excel

For a GTIN-13 body of 12 digits stored as text in cell A1, this formula returns the check digit.

=MOD(10-MOD(SUMPRODUCT(--MID(A1,{1,3,5,7,9,11},1))+3*SUMPRODUCT(--MID(A1,{2,4,6,8,10,12},1)),10),10)

Store identifiers as text, never as numbers. Excel keeps only 15 significant digits in a number, so an 18-digit SSCC stored as a number loses its last digits. It also drops leading zeros, which corrupts GTIN-12 and GTIN-8 values.

GS1 check digit in SQL

This query uses a recursive common table expression. It was tested in SQLite and returns 1 for the GTIN-13 body and 7 for the SSCC body used above. Adapt the syntax to your database dialect.

WITH RECURSIVE d(i, n) AS (
  SELECT 1, LENGTH('400638133393')
  UNION ALL
  SELECT i + 1, n FROM d WHERE i < n
)
SELECT (10 - (SUM(CAST(SUBSTR('400638133393', i, 1) AS INTEGER)
                * CASE WHEN (n - i) % 2 = 0 THEN 3 ELSE 1 END) % 10)) % 10
       AS check_digit
FROM d;

GS1 check digit in PLC structured text

This function follows IEC 61131-3 string functions. Vendors differ in details such as string conversion names, so run it against the vectors in Appendix B on your own runtime.

FUNCTION GS1_CheckDigit : INT
VAR_INPUT
    sBody : STRING(17);
END_VAR
VAR
    i, n, iSum : INT;
END_VAR

n := LEN(sBody);
iSum := 0;
FOR i := 1 TO n DO
    IF ((n - i) MOD 2) = 0 THEN
        iSum := iSum + 3 * STRING_TO_INT(MID(sBody, 1, i));
    ELSE
        iSum := iSum + STRING_TO_INT(MID(sBody, 1, i));
    END_IF
END_FOR
GS1_CheckDigit := (10 - (iSum MOD 10)) MOD 10;

CRC-32 in C

The bitwise version is the shortest and easiest to audit. It was compiled and tested against the vector for the ASCII string 123456789. Production code usually switches to a table or a hardware peripheral.

uint32_t crc32_update(uint32_t crc, const uint8_t *data, size_t len)
{
    while (len--) {
        crc ^= *data++;
        for (int bit = 0; bit < 8; bit++) {
            crc = (crc >> 1) ^ (0xEDB88320u & (0u - (crc & 1u)));
        }
    }
    return crc;
}

/* Start with 0xFFFFFFFF, feed every chunk, finish with a final XOR:
   crc = 0xFFFFFFFFu;
   crc = crc32_update(crc, buffer, length);
   crc ^= 0xFFFFFFFFu;
   The result for the ASCII string 123456789 is 0xCBF43926. */

Modbus CRC-16 and streaming SHA-256 in Python

import hashlib

def crc16_modbus(data: bytes) -> int:
    crc = 0xFFFF
    for byte in data:
        crc ^= byte
        for _ in range(8):
            crc = (crc >> 1) ^ 0xA001 if crc & 1 else crc >> 1
    return crc

frame = bytes([0x01, 0x03, 0x00, 0x00, 0x00, 0x0A])
crc = crc16_modbus(frame)
wire = frame + bytes([crc & 0xFF, crc >> 8])   # low byte first

def sha256_file(path, chunk=1024 * 1024):
    h = hashlib.sha256()
    with open(path, 'rb') as f:
        for block in iter(lambda: f.read(chunk), b''):
            h.update(block)
    return h.hexdigest()

The variable wire holds 01 03 00 00 00 0A C5 CD. The streaming function reads the file in chunks, so it handles images of any size with constant memory. To experiment with checksums of hex and ASCII strings, try the Hex and ASCII Checksum Calculator on this site.

Pitfalls in Checksum Implementations

Pitfall What happens Countermeasure
Byte order Modbus sends the CRC low byte first. Swapped bytes fail every frame Verify against a captured frame from a real device
Initial value and reflection A different parameter set produces a plausible but wrong CRC Fix all six CRC parameters in the interface specification
Text versus bytes Line endings, text encoding and trailing spaces change a digest Hash the exact stored bytes, and define the normalization if text is involved
Numeric types for identifiers Leading zeros vanish, long numbers lose digits in floating point Store identifiers as strings in Excel, CSV, databases and PLC data
Loading whole files into memory Large images exhaust RAM on the station Hash in chunks
Undefined coverage The digest includes volatile fields such as serial numbers Define the exact regions, and exclude or patch unit-specific data
Unverified libraries A silent bug passes every test that you did not write Run published vectors in the build pipeline

26. Best-practice checklist by role

R&D and design

  • Define a check digit and a fixed format in every identifier scheme, starting with the first draft of the numbering concept.
  • Give firmware images a header with magic number, version, length, CRC and signature, and specify the behaviour on failure.
  • Document CRC parameters and the reasoning for the polynomial in the interface specification.
  • Store hashes of released packages in the release record and in supplier transmittals.
  • Include diagnostic coverage of memory and communication checks in the safety analysis.

Manufacturing

  • Run scan and flash stations as gates with hard stops, and log every bypass.
  • Verify firmware by readback or by a device-reported digest, and record the result per serial number.
  • Compare active recipes with the golden hash at the start of each lot.
  • Challenge each check with a known-bad sample every shift.
  • Keep verifiers and scanners calibrated and maintained.
Fmea detection
Implement robust quality assurance processes to enhance product reliability through systematic testing and validation.

Quality

  • Rate FMEA detection from evidence, such as challenge test results and bypass records.
  • Validate the checks, and keep the test vectors in the validation file.
  • Run mock recalls and track the time to the list of affected units.
  • Chart scan failure rates and verification grades, and act on trends.
  • Match supplier certificates automatically against purchase order and receiving data.
  •  

Logistics

  • Scan to confirm location, item and container at each pick.
  • Validate identifiers and messages at receipt, and track the rejection rate per trading partner.
  • Allocate SSCCs centrally and enforce uniqueness.
  • Verify labels at the point of labeling and use 2D symbols for long or rough supply chains.
  • Express targets in defects per million lines.

IT and OT

  • Provide one shared library or service for check digits, CRCs and hashes, with published test vectors.
  • Sign firmware and builds, keep private keys in a hardware security module, and plan rotation and revocation.
  • Synchronize clocks and keep records in append-only stores or hash chains with external anchoring.
  • Store identifiers as strings in every system that touches them.
  • Plan algorithm agility, because SHA-1 is being retired and post-quantum signatures are coming.

Two pro tips for engineers

  • Name one owner for every check. That person maintains the algorithm, the parameters, the test vectors and the reaction plan.
  • Put each check into the control plan and the process FMEA, and audit it on the same schedule as a measurement system.
Checksums
Integrating robust checksums and controlled processes enhances product lifecycle integrity and reliability.

Conclusion on Checksums and Similar

Checksums are small, old and well understood. Their value in physical product work comes from placing the right one at the right point of the lifecycle, and from treating the check as a controlled process with evidence.

Use check digits where people and scanners handle identifiers. Use CRCs for frames, blocks and images, with a polynomial that fits the message length. Use SHA-256 for files and records, and signatures or keyed codes wherever deliberate change is a risk. Add error correction where marks and memories will be damaged.

Then close the loop with evidence. Challenge the checks, calibrate the verifiers, record the results and review the numbers. A check that nobody tests is an assumption.

 

Pilot on the hand-off with the highest cost per escape and no check today. Measure the escape rate before and after, and use the result to justify the next one.

Treat every check as a controlled item with a specification, an owner, test vectors and a challenge frequency. A check without these will decay.

 

FAQ

Why does a passing CRC-32 not prove that a firmware image is the intended release?

A CRC detects accidental corruption only, and anyone can craft a modified image that carries the same CRC. Verify a SHA-256 digest against a release record that reaches you through a separate channel, and add a signature wherever deliberate change is a risk.

Which errors escape a GS1 mod-10 check digit?

The check catches every single-digit error, but it misses adjacent transpositions of digits that differ by 5, about 11 percent of swaps of different digits. A valid digit also proves nothing about allocation, so keep master-data validation next to the arithmetic check.

How should I rate FMEA detection for a checksum-based control?

Rate the evidence and not the algorithm: an automated hard stop that was challenged with known-bad samples earns a much better rating than a check that operators can bypass or that was never challenged. Quantify the escape probability, keep the challenge log and the bypass register, and apply the AIAG-VDA 2019 action priority logic.

How do I choose a CRC polynomial for my interface?

The guaranteed Hamming distance depends on both the polynomial and the message length, so fix the length range first. Koopman showed that the IEEE 802.3 CRC-32 reaches only a Hamming distance of 4 on maximum-length Ethernet frames, while other polynomials reach 6, so take the polynomial from published exhaustive-search results.

Why do two systems that both claim to use CRC-16 disagree on every frame?

The name does not define the algorithm, because width, polynomial, initial value, input reflection, output reflection and final XOR must all match. Write the six parameters into the interface specification and test both ends with the check value of the ASCII string 123456789 from the Reveng catalogue.

When is a SHA-256 comparison at end of line still not proof of a correct flash?

Hashing the source file, or trusting the success flag of the programmer, says nothing about the contents of the device. Read the region back from the device through a separate path, include option bytes, fuses and lock bits, handle unit-specific data such as serial number, MAC address and calibration separately, and record the result per serial number.

Is a hash chain enough to make batch records tamper-evident?

A chain proves order and integrity only if its latest hash is anchored outside the system that holds the log. Use periodic signing, RFC 3161 trusted timestamps, or send the hash to a customer or auditor, because anyone with write access can otherwise recompute the whole chain.

Where does a fieldbus CRC stop protecting my signals?

A gateway or bridge recomputes the CRC for the next segment, so corruption inside its memory between the two hops goes unseen. For safety-relevant signals and setpoints, add an end-to-end CRC with a counter that is generated at the source and verified at the consumer.

How many bits does a non-cryptographic hash need for inventories and deduplication?

The birthday bound decides it: a 32-bit hash with 100,000 items has a collision probability of about 69 percent, while a 64-bit hash with one million items stays near 2.7 in 100 million. Use 64 bits or more, and compare the full data whenever a match drives a decision.

How do I treat barcode scanners and verifiers in a measurement system analysis?

Calibrate verifiers with a conformance standard test card, apply ISO/IEC 15416, 15415 or 29158 to the symbol type, and run an attribute agreement analysis between operators, scanners and a reference. A symbol that reads successfully has shown only that it reads, so track the grade distribution and the unused error-correction capacity as drift indicators.

Do I need to validate the check function itself in a regulated environment?

Yes, because the check is part of a computerized system that falls under GAMP 5 principles, 21 CFR Part 11 or EU Annex 11. Plan IQ, OQ and PQ in proportion to risk, store test vectors and negative tests in the validation file, and rerun them after any change of scanner firmware, printer, library or operating system.

How do I plan for algorithm retirement in products that stay in service for 10 to 20 years?

Keep an algorithm register with review dates, for example for the NIST plan to retire SHA-1 by 31 December 2030. Design bootloaders and update channels so that algorithms and keys can be replaced in the field, since the Cyber Resilience Act makes signed and verified updates a compliance matter from 11 December 2027.

 

Appendices

Appendix A: Test vectors

All values were computed or confirmed with the code shown in chapter 25 or with reference tools. All input strings are given as ASCII text.

Function Input Expected result
CRC-32 123456789 0xCBF43926
CRC-32C 123456789 0xE3069283
CRC-16/MODBUS 123456789 0x4B37
CRC-16/CCITT-FALSE 123456789 0x29B1
CRC-8 (polynomial 0x07) 123456789 0xF4
SHA-256 123456789 15e2b0d3c33891ebb0f1ef609ec419420c20e320ce94c65fbc8c3312448eb225
Modbus RTU frame 01 03 00 00 00 0A CRC 0xCDC5, sent as C5 CD
CRC-3 teaching example Message 1101, generator 1011 Remainder 001
GTIN-13 check digit 400638133393 1, full key 4006381333931
GTIN-12 check digit 03600029145 2, full key 036000291452
GTIN-14 check digit 1540014128876 3, full key 15400141288763
SSCC check digit 34012345000000001 7, full key 340123450000000017
Luhn check digit 7992739871 3, full number 79927398713
VIN check digit (North American rule) 11111111111111111 1
VIN check digit (North American rule) 1HGBH41JXMN109186 X in position 9

Appendix B: Standards and references

Online sources used for this article, checked in November 2026:

Standards and publications cited by name, available from the issuing bodies:

  • RFC 1071 (Internet checksum), RFC 2104 (HMAC), RFC 3161 (timestamp protocol)
  • FIPS 180-4 (SHA-1 and SHA-2), FIPS 202 (SHA-3), NIST SP 800-38B (CMAC)
  • ISO/IEC 7064 (check character systems), ISO 6346 (container codes), ISO/IEC 29158 (direct part mark quality)
  • ISO 9001, IATF 16949, AS9100, ISO 13485, ISO 26262, IEC 61508, IEC 62304, IEC 62443
  • AIAG and VDA FMEA Handbook, 1st edition, 2019
  • 21 CFR Part 11, EU GMP Annex 11, GAMP 5
  • Maxino and Koopman, The Effectiveness of Checksums for Embedded Control Networks, IEEE Transactions on Dependable and Secure Computing, 2009
  • Regulation (EU) 2024/2847 (Cyber Resilience Act), Regulation (EU) 2024/1781 (Ecodesign for Sustainable Products), Regulation (EU) 2023/1542 (Batteries), Directive (EU) 2022/2555 (NIS2)
10th year anniversary

Full size images and downloads are only available, 100% free, for registered members.

> Login <