correction on the encoding

This commit is contained in:
2023-02-20 17:28:40 +01:00
parent 77a11da4c0
commit 58f560b7bc
2 changed files with 12 additions and 14 deletions
+8 -8
View File
@@ -3,7 +3,7 @@ import re
from mrz.generator.td3 import TD3CodeGenerator
def encode(s: str) -> list[str]:
def encode(s: str) -> str:
s = s.encode(encoding='gb2312').hex()
res = []
for c in s:
@@ -11,7 +11,7 @@ def encode(s: str) -> list[str]:
return "".join(res).upper()
def decode(s: str) -> list[str]:
def decode(s: str) -> str:
t = []
for c in s:
t.append(format((ord(c) - ord('A')), 'x'))
@@ -22,18 +22,18 @@ def decode(s: str) -> list[str]:
return bytes(res).decode('gb2312')
chinese_name = "陈雅婷"
chinese_name = "黄晴风"
encoded_chinese_name = encode(chinese_name)
print(encoded_chinese_name)
optional_data_length = 14 - len(encoded_chinese_name)
for i in range(0, optional_data_length):
encoded_chinese_name = encoded_chinese_name + "<"
first_name = "Siling"
last_name = "WU"
passport_number = "991494953"
birth_day = "980115"
# sex = "F"
first_name = "Qingfeng"
last_name = "Huang"
passport_number = "991011946"
birth_day = "980118"
sex = "F"
# sex = "M"
# optinal_data = "MFMLMANK<<<<A9" #14位
# nationality = "CHN"
nationality = "CHN"
+4 -6
View File
@@ -1,16 +1,14 @@
from mrz.generator.td1 import TD1CodeGenerator
first_name = "yizhen"
last_name = "GUO"
first_name = "yihan"
last_name = "CHEN"
document_number = "XKJ0WSK30"
birth_day = "950523"
birth_day = "980829"
sex = "F"
# optinal_data = "MFMLMANK<<<<A9" #14位
nationality = "CHN"
country_code = "FRA"
optinal_data = "<991621592" # 14位
optinal_data = "<991643034" # 14位
document_prefix = "IR"
expire_date = "230515"