Machine-readable record of documents (passports) of the Russian Federation

CarderPlanet

Professional
Messages
2,556
Reputation
7
Reaction score
586
Points
83
What is this article about
This article will consider the algorithm for forming the field of civil and foreign passports, known as the MChZ, machine-readable record (MRZ, machine-readable zone). This field is the two lines printed by the printer at the bottom of the main spread of the passport.

Who is this article for
This article may be of interest, among others, to the following categories of specialists:

1) layout designers of scans or photographs of documents according to the specified data (name, date of birth, and so on). This article will help, having a scan with other data, adjust the MCHZ accordingly.

2) to retouchers of passports ("re-gluers"). In case of changing the setting data in the passport, it is necessary to change the MCHZ (similar to clause 1)

Subject of the article
With the development of transport communications, especially international ones, and an increase in passenger traffic, the problem of accounting (and, if you will, control) of passenger passport data arose. It is not hard to guess that this problem has become most acute in the field of air transportation.

Given the rich variety of passport formats in different countries, it was decided to define a new format specifically for automated processing. This format is described in the ICAO standard (International Civil Aviation Organization, International Civil Aviation Organization) number 9303 [1]. It (part I, volume I, section IV), in particular, describes the format of those very printed lines at the bottom of the main spread of the passport (the so-called zone VII). In Russian translation, this standard is also known as GOST R 52535.1-2006 [2].

So, in two lines, 44 characters each, indicate:

1) document type, characters 1-2 of the first line. The first character is always P (specified in the standard). The second character can be used by the organization (country) that issued the passport to distinguish between the types of passports. In the case of documents of the Russian Federation - P <for a passport, PN for an internal passport, PD for a dimplomatic passport. Presumably, PS for a service passport (I did not hold it in my hands).

2) country / organization issuing the passport, characters 3-5 of the first line. The list of possible values is also determined by the standard (Appendix VII), RUS for the Russian Federation.

3) surname, name and, depending on the type of passport, patronymic of the owner. Characters 6-44 of the first line. If necessary, the line can be trimmed in a certain way. The last name is separated from the rest of the line by a double filler character (<<), parts of the compound surname, first name, patronymic, and first and middle names are separated by a placeholder (<)

4) passport number with a check digit, characters 1-10 of the second line.

5) citizenship of the passport holder (similar to clause 2), characters 11-13 of the second line.

6) date of birth with a check digit , characters 14-20 of the second line.

7) gender (M - male, F - female), character 21 of the second line.

8) expiration date with a check digit, characters 22-28 of the second line.

9) personal number with a check digit, characters 29-43 of the second line. The format of this column is left to the mercy of the organization issuing the passport. In the case of documents of the Russian Federation, there is either an empty string (with a check digit 0 or a <symbol), or a string of numbers.

10) check digit for pp. 4,6,8,9. Always a figure in the case of documents of the Russian Federation.

All check digits are calculated as the remainder of the division by 10 of the sum of the weighted character values. The weighting factors are a looped sequence (7,3,1,7,3,1, ...) In the case of an empty string, a fill character (<) can be used instead of a check digit

Consider further how this applies to different types of passports.

Passport of a citizen of the Russian Federation of a new sample
The rules for the formation of the MCHZ are described in the appendix to the order N 279 of the FMS of Russia dated June 30, 2011 [3] [4]. The nuances are as follows:
1) surname, name, patronymic are transliterated using the established table. The resulting string is truncated if necessary.
2) the passport number (in the MCHZ categories) is formed by concatenating the series (without the last digit) and the actual passport number in terms of the FMS.
3) no expiration date is specified (placeholder characters <)
4) the personal number is formed by concatenating the last digit of the series, the date of issue of the passport, the code of the FMS unit that issued the passport and the filler sign.

Passport of the Russian Federation of the old model
Nuances:
1) Patronymic is not entered
2) Personal number is not entered, instead of the corresponding check digit, a placeholder (<) is entered

Russian foreign passport of a new sample (biometric)
Filling in the MCHZ is carried out by analogy with the old-style passport, but 0 is indicated as the check digit of the personal number (symbol 43 of the second line)

As you can see, the MCHZ format and the checksum generation algorithm are quite simple, but each time manually filling the MCHZ, constantly consulting the standards, is rather inconvenient. Therefore, a web application is offered to your attention, which allows you to generate the corresponding MCHZ based on the input data, as well as check the MCHZ for correctness. The application is written in python (version 2.7) using the micro (or even nano) bottle framework. The front end uses bootstrap for beauty and jQuery for interactive filtering of input, so it is advisable to enable javascript in the browser. The focus on the user using the browser made it quite easy to use the font set by the standard. Paranoid people can run an application with disabled javascript or access to the network, but then I will not see an extraordinary title.

Using the app
1) bottle installation (possibly inside a virtual environment)
Code:
pip install bottle

2) launching the application

Code:
python app.py

3) opening the page
Code:
localhost: 5000

4) selection of a menu item, data entry

5) profit!

Further ideas for the application
1) add automatic transliteration for passports

2) it is probably worth rewriting in Flask using WTForms for improved verification of entered data.

3) think about the possibility of describing a passport of an arbitrary country through the enumeration of fields (analogous to models in Django)

4) think about changing the interface (try tkinter or qt)

5) add the generation of MCHZ in the form of a raster file for further layout with the choice of the desired resolution

Some conclusions
1) string fields (full name, gender) do not have a check digit, there is nothing to worry about when editing them

2) if, when publishing a scan of a document for any purpose, you paint over the installation data, do not forget about their duplicate in the Ministry of Health

3) you can judge on your own about the truthfulness of urban legends about the numbers in the passport (supposedly the last figure means either the number of people similar to the owner, or the category of accounting "where necessary", etc.).

Footnotes:
[1] (clearnet) http://www.icao.int/publications/pages/publication.aspx?docnum=9303

[2] (clearnet) http://protect.gost.ru/document.aspx?control=7&id=128725

[3] (clearnet) http://www.rg.ru/2011/09/21/pasport-dok.html

[4] (clearnet) http://www.fms.gov.ru/upload/files/mashchz.pdf
 
Top