Skip to main content

Decode, decrypt and parse South Africa driving license

Project description

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, which requires a license key.

South Africa Driving License Parser

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

south-africa-driving-license-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file south-africa-driving-license-0.1.1.tar.gz.

File metadata

File hashes

Hashes for south-africa-driving-license-0.1.1.tar.gz
Algorithm Hash digest
SHA256 971ea98c941cf48b5e21e3d590105bcc67a7fb57e1474f45021c727c37a6aad2
MD5 a4a6d1770ddfb3d1ee75f117ba768f74
BLAKE2b-256 61b18b13c680fe11db44501e504a12eccbb17c20a64ca66eaefc1d14984a3fe9

See more details on using hashes here.

File details

Details for the file south_africa_driving_license-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for south_africa_driving_license-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 625eb683f4322d4173d24404bd6540574c135a132ff945b901b1a3f1d8149ea0
MD5 e3c84734ca2690d982a9742f8aa179a3
BLAKE2b-256 bbae788bb764045cb0b3c8927ef467aac3c117433973b4b1e611a4d5d7a1b47a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page