我正在为iOS编写一个扫描南非驾照背面PDF417条形码(http://en.wikipedia.org/wiki/PDF417)的解决方案。我找不到任何关于如何解码条形码的文档或规范。有没有人有链接到可以解码存储在PDF417条形码中的驾驶执照数据的规范或示例代码?谢谢。
我正在为iOS编写一个扫描南非驾照背面PDF417条形码(http://en.wikipedia.org/wiki/PDF417)的解决方案。我找不到任何关于如何解码条形码的文档或规范。有没有人有链接到可以解码存储在PDF417条形码中的驾驶执照数据的规范或示例代码?谢谢。
01 e1 02 45
版本2: 01 9b 09 45
接下来两个字节为零(00 00
)。-----BEGIN RSA PUBLIC KEY-----
MIGXAoGBAP7S4cJ+M2MxbncxenpSxUmBOVGGvkl0dgxyUY1j4FRKSNCIszLFsMNw
x2XWXZg8H53gpCsxDMwHrncL0rYdak3M6sdXaJvcv2CEePrzEvYIfMSWw3Ys9cRl
HK7No0mfrn7bfrQOPhjrMEFw6R7VsVaqzm9DLW7KbMNYUd6MZ49nAhEAu3l//ex/
nkLJ1vebE3BZ2w==
-----END RSA PUBLIC KEY-----
版本 1,74 字节:
-----BEGIN RSA PUBLIC KEY-----
MGACSwD/POxrX0Djw2YUUbn8+u866wbcIynA5vTczJJ5cmcWzhW74F7tLFcRvPj1
tsj3J221xDv6owQNwBqxS5xNFvccDOXqlT8MdUxrFwIRANsFuoItmswz+rfY9Cf5
zmU=
-----END RSA PUBLIC KEY-----
版本2,128字节:
-----BEGIN RSA PUBLIC KEY-----
MIGWAoGBAMqfGO9sPz+kxaRh/qVKsZQGul7NdG1gonSS3KPXTjtcHTFfexA4MkGA
mwKeu9XeTRFgMMxX99WmyaFvNzuxSlCFI/foCkx0TZCFZjpKFHLXryxWrkG1Bl9+
+gKTvTJ4rWk1RvnxYhm3n/Rxo2NoJM/822Oo7YBZ5rmk8NuJU4HLAhAYcJLaZFTO
sYU+aRX4RmoF
-----END RSA PUBLIC KEY-----
版本2,74字节:
-----BEGIN RSA PUBLIC KEY-----
MF8CSwC0BKDfEdHKz/GhoEjU1XP5U6YsWD10klknVhpteh4rFAQlJq9wtVBUc5Dq
bsdI0w/bga20kODDahmGtASy9fae9dobZj5ZUJEw5wIQMJz+2XGf4qXiDJu0R2U4
Kw==
-----END RSA PUBLIC KEY-----
将每个块分开解密。使用公钥,用RSA ENCRYPT函数进行解密。
pubKey = rsa.PublicKey.load_pkcs1(pk128)
all = bytearray()
pubKey = rsa.PublicKey.load_pkcs1(pk128)
start = 6
for i in range(5):
block = data[start: start + 128]
input = int.from_bytes(block, byteorder='big', signed=False)
output = pow(input, pubKey.e, mod=pubKey.n)
decrypted_bytes = output.to_bytes(128, byteorder='big', signed=False)
all += decrypted_bytes
start = start + 128
pubKey = rsa.PublicKey.load_pkcs1(pk74)
block = data[start: start + 74]
input = int.from_bytes(block, byteorder='big', signed=False)
output = pow(input, pubKey.e, mod=pubKey.n)
decrypted_bytes = output.to_bytes(74, byteorder='big', signed=False)
all += decrypted_bytes
def parse_data(data):
index = 0
for i in range(0, len(data)):
if data[i] == 0x82:
index = i
break
# Section 1: Strings
vehicleCodes, index = readStrings(data, index + 2, 4)
print(f'Vehicle codes: {vehicleCodes}')
surname, index, delimiter = readString(data, index)
print(f'Surname: {surname}')
initials, index, delimiter = readString(data, index)
print(f'Initials: {initials}')
PrDPCode = ''
if delimiter == 0xe0:
PrDPCode, index, delimiter = readString(data, index)
print(f'PrDP Code: {PrDPCode}')
idCountryOfIssue, index, delimiter = readString(data, index)
print(f'ID Country of Issue: {idCountryOfIssue}')
licenseCountryOfIssue, index, delimiter = readString(data, index)
print(f'License Country of Issue: {licenseCountryOfIssue}')
vehicleRestrictions, index = readStrings(data, index, 4)
print(f'Vehicle Restriction: {vehicleRestrictions}')
...
pip install south-africa-driving-license
来安装它。