Menu

1 / 2

How passport MRZ check digits work, with code to validate them

DEV Community: computervision·Ali Ahmed·1 day ago
#UYgFAIfP
Reading 0:00
15s threshold

Video: Computing a passport MRZ check digit, step by step

The machine-readable zone (MRZ) is the block of uppercase letters, digits and < chevrons at the bottom of a passport data page. It repeats the key fields in a fixed format defined by ICAO Document 9303 , and it carries check digits : each important field is followed by one digit computed from it with weights 7, 3, 1 . A KYC pipeline uses them to catch OCR mistakes and some tampering. If a single character in the document number is misread, its check digit almost always stops matching. Here's how the algorithm works, with tested Python.

What does an MRZ look like?

A passport (format TD3 ) has two lines of 44 characters.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.