Python Decoder for Driving License in South Africa
The Python project is used to decode, decrypt and parse South African driving licenses. The PDF417 decoding part relies on Dynamsoft Barcode Reader via the dynamsoft-barcode-reader-bundle package, which requires a license key.
Installation
pip install dynamsoft-barcode-reader-bundle
Command-line Usage
$ sadltool [-t TYPES] [-e ENCRYPTED] [-l LICENSE] source
positional arguments:
source A source file containing information of driving license.
options:
-h, --help show this help message and exit
-t TYPES, --types TYPES
Specify the source type. 1: PDF417 image 2: Base64 string 3: Raw bytes
-e ENCRYPTED, --encrypted ENCRYPTED
Is the source encrypted? 0: No 1: Yes
-l LICENSE, --license LICENSE
The license key is required for decoding PDF417
Try Project Examples:
python test.py images/dlbase64.txt -t 2 -e 0
python test.py images/dl.raw -t 3 -e 0
python test.py images/dl.png -l <Dynamsoft Barcode Reader License Key>
Sample Code
import argparse
from sadl import *
import sys
import os
def sadltool():
parser = argparse.ArgumentParser(description='Decode, decrypt and parse South Africa driving license.')
parser.add_argument('source', help='A source file containing information of driving license.')
parser.add_argument('-t', '--types', default=1, type=int, help='Specify the source type. 1: PDF417 image 2: Base64 string 3: Raw bytes')
parser.add_argument('-e', '--encrypted', default=1, type=int, help='Is the source encrypted? 0: No 1: Yes')
parser.add_argument('-l', '--license', default='', type=str, help='The license key is required for decoding PDF417')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
try:
args = parser.parse_args()
source = args.source
types = args.types
if args.encrypted == 1:
encrypted = True
else:
encrypted = False
license = args.license
if not os.path.exists(source):
print('Source not found')
exit(-1)
if types == 1:
dl = parse_file(source, encrypted, license)
print(dl)
elif types == 2:
with open(source, 'r') as f:
source = f.read()
dl = parse_base64(source, encrypted)
print(dl)
elif types == 3:
data = Path(source).read_bytes()
dl = parse_bytes(data, encrypted)
print(dl)
except Exception as err:
print(err)
sys.exit(1)
sadltool()
How to Build the Package
-
Source distribution:
python setup.py sdist
-
Wheel:
pip wheel . --verbose # Or python setup.py bdist_wheel
References
Metadata
Release files for south-africa-driving-license 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| south_africa_driving_license-0.2.1.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| south_africa_driving_license-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.4 kB
Release files / south_africa_driving_license-0.2.1.tar.gz
| Download URL | south_africa_driving_license-0.2.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9722a9901cc0748b843588be210d96ad1af096bf0c87a5613aba3b190c109433
|
|
BLAKE2b-256 checksum How to use checksums |
6e7e3664b724ff610e922b6324ee0d6c358118c1ab7311e1fd8d9587bf4a5e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / south_africa_driving_license-0.2.1-py3-none-any.whl
| Download URL | south_africa_driving_license-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5febba1aefc76a3198b7769a8b302d50b5506d70c395009a403077aee40edf5b
|
|
BLAKE2b-256 checksum How to use checksums |
b80b88a8e32d311bad1d681d17765703ad4f8bdd959ee7937e6866dbabb615b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|