护照、签证、身份证和其他旅行证件的机器可读区域生成器和检查器
mrz的Python项目详细描述
说明:
公务旅行机读区域生成器和检查器 文件尺寸1、2、3、MRVA和MRVB(护照、签证、国民身份证 卡片和其他旅行证件)
mrz发生器和mrz检查器按照国际民用 航空组织规范(国际民航组织9303):
- Specifications Common to all Machine Readable Travel Documents (MRTDs)
- Specifications for Machine Readable Passports (MRPs)
- Specifications for TD1 Size Machine Readable Official Travel Documents (MROTDs)
- Specifications for TD2 Size Machine Readable Official Travel Documents (MROTDs)
- Specifications for Machine Readable Visas (MRV)
公务旅行证件现场发放:
图像
使用生成器:
TD1(身份证):
Params: Case insensitive document_type (str): The first letter shall be 'I', 'A' or 'C' country_code (str): 3 letters code (ISO 3166-1) or country name (in English) document_number (str): Document number birth_date (str): YYMMDD sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X' expiry_date (str): YYMMDD nationality (str): 3 letters code (ISO 3166-1) or country name (in English) surname (str): Holder primary identifier(s). This field will be transliterated given_names (str): Holder secondary identifier(s). This field will be transliterated optional_data1 (str): Optional personal data at the discretion of the issuing State. Non-mandatory field. Empty string by default optional_data2 (str): Optional personal data at the discretion of the issuing State. Non-mandatory field. Empty string by default transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default force (bool): Disables checks for country, nationality and document_type fields. Allows to use 3-letter-codes not included in the countries dictionary and to use document_type codes without restrictions.
TD2
Params: Case insensitive document_type (str): The first letter shall be 'I', 'A' or 'C' country_code (str): 3 letters code (ISO 3166-1) or country name (in English) surname (str): Holder primary identifier(s). This field will be transliterated. given_names (str): Holder secondary identifier(s). This field will be transliterated. document_number (str): Document number. nationality (str): 3 letters code (ISO 3166-1) or country name birth_date (str): YYMMDD sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X' expiry_date (str): YYMMDD optional_data (str): Optional personal data at the discretion of the issuing State. Non-mandatory field. Empty string by default transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default force (bool): Disables checks for country, nationality and document_type fields. Allows to use 3-letter-codes not included in the countries dictionary and to use document_type codes without restrictions.
TD3(护照)
Params: Case insensitive document_type (str): Normally 'P' for passport country_code (str): 3 letters code (ISO 3166-1) or country name (in English) surname (str): Primary identifier(s) given_names (str): Secondary identifier(s) passport_number (str): Passport number nationality (str): 3 letters code (ISO 3166-1) or country name birth_date (str): YYMMDD sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X' expiry_date (str): YYMMDD optional data (str): Personal number. In some countries non-mandatory field. Empty string by default transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default force (bool): Disables checks for country, nationality and document_type fields. Allows to use 3-letter-codes not included in the countries dictionary and to use document_type codes without restrictions.
MRVA(A类签证)
Params: Case insensitive document_type (str): The First letter must be 'V' country_code (str): 3 letters code (ISO 3166-1) or country name (in English) surname (str): Primary identifier(s) given_names (str): Secondary identifier(s) passport_number (str): Passport number nationality (str): 3 letters code (ISO 3166-1) or country name birth_date (str): YYMMDD sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X' expiry_date (str): YYMMDD optional_data (str): Optional personal data at the discretion of the issuing State. Non-mandatory field. Empty string by default. transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default force (bool): Disables checks for country, nationality and document_type fields. Allows to use 3-letter-codes not included in the countries dictionary and to use document_type codes without restrictions.
MRVB(B类签证)
Params: Case insensitive document_type (str): The First letter must be 'V' country_code (str): 3 letters code (ISO 3166-1) or country name (in English) surname (str): Primary identifier(s) given_names (str): Secondary identifier(s) passport_number (str): Passport number nationality (str): 3 letters code (ISO 3166-1) or country name birth_date (str): YYMMDD sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X' expiry_date (str): YYMMDD optional_data (str): Optional personal data at the discretion of the issuing State. Non-mandatory field. Empty string by default. transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default force (bool): Disables checks for country, nationality and document_type fields. Allows to use 3-letter-codes not included in the countries dictionary and to use document_type codes without restrictions.
护照生成器示例(ICAO9303样本):
图像
TD3代码生成器->;str:
frommrz.generator.td3importTD3CodeGeneratorcode=TD3CodeGenerator("P","UTO","Eriksson","Anna María","L898902C3","UTO","740812","F","120415","ZE184226B")print(code)
输出:
P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<< L898902C36UTO7408122F1204159ZE184226B<<<<<10
注意:参见mrz.generator examples folder中的其他用法
使用情况检查器:
TD1(身份证):
Params: mrz_string (str): MRZ string of TD1. Must be 90 uppercase characters long (3 lines) check_expiry (bool): If it's set to True, it is verified and reported as warning that the document is not expired and that expiry_date is not greater than 10 years compute_warnings (bool): If it's set True, warnings compute as False
TD2:
Params: mrz_string (str): MRZ string of TD2. Must be 72 characters long (uppercase) (2 lines) check_expiry (bool): If it's set to True, it is verified and reported as warning that the document is not expired and that expiry_date is not greater than 10 years compute_warnings (bool): If it's set True, warnings compute as False
TD3(护照):
Params: mrz_string (str): MRZ string of TD3. Must be 88 characters long (uppercase) (2 lines) check_expiry (bool): If it's set to True, it is verified and reported as warning that the document is not expired and that expiry_date is not greater than 10 years compute_warnings (bool): If it's set True, warnings compute as False
磁共振血管成像:
Params: mrz_string (str): MRZ string of Visas type A. Must be 88 characters long (uppercase) (2 lines) check_expiry (bool): If it's set to True, it is verified and reported as warning that the document is not expired and that expiry_date is not greater than 10 years compute_warnings (bool): If it's set True, warnings compute as False
mrvb:
Params: mrz_string (str): MRZ string of Visas type B. Must be 72 characters long (uppercase) (2 lines) check_expiry (bool): If it's set to True, it is verified and reported as warning that the document is not expired and that expiry_date is not greater than 10 years compute_warnings (bool): If it's set True, warnings compute as False
身份证检查器示例
![image](https://warehouse-camo.cmh1.psfhosted.org/a82739db88e3440f702658597ba6e00dd62e9a33/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f4172673073313038302f6d727a2f6d61737465722f646f63732f696d616765732f69645f63617264732f53776564656e2e706e67)
图像
图像
td1代码检查器->;bool
frommrz.checker.td1importTD1CodeCheckerresult=bool(TD1CodeChecker("I<SWE59000002<8198703142391<<<\n""8703145M1701027SWE<<<<<<<<<<<8\n""SPECIMEN<<SVEN<<<<<<<<<<<<<<<<"))print(result)
字段提取示例(对TD1、TD2、TD3和签证有效)
frommrz.checker.td1importTD1CodeChecker,get_countrytd1_check=TD1CodeChecker("IDLIEID98754015<<<<<<<<<<<<<<<\n""8205122M1906224LIE<<<<<<<<<<<6\n""OSPELT<BECK<<MARISA<<<<<<<<<<<")fields=td1_check.fields()print(fields.name,fields.surname)print(get_country(fields.country))
安装:
通过pip(可能不是最新版本):
sudo -H pip install mrz
克隆此回购协议(可能无法正常工作):
git clone https://github.com/Arg0s1080/mrz.git cd mrz sudo python3 setup.py install
特点:
- [X]特殊拉丁字符的音译(acutes,tildes, 分封、坟墓、回旋曲等)
- [x]阿拉伯字符音译
- [X]增加了几种西里尔语变体:塞尔维亚语、马其顿语, 白俄罗斯语、乌克兰语和保加利亚语
- 现代希腊语音译(实验)
- [X]现代希伯来语(无元音)音译(实验性)
- [X]根据其英文名称生成国家代码(例如: “荷兰”->;“荷兰”)
- [X]名称截断检测
- [X]检查程序中的错误报告、警告报告和完整报告。
- [X]警告计算为错误的可能性 检查程序中的compute_warnings关键字。
- [x]禁用国家代码、国籍和 文件类型,允许使用 国家词典和使用不带 发电机堵塞
- [X]在checker中添加了一段时间的新支票。
- [X]签证支持
- [X]在checker中提取字段(姓名、姓氏、国家、性别等) (版本0.5.0)
待办事项:
- []生成器中的自动名称截断
- []禁用国家代码、国籍检查的可能性, checker中的文档类型和其他字段。
- []添加日志记录