GithubHelp home page GithubHelp logo

sa-license-decoder's Introduction

ZA Drivers License Decoding

This purpose of the project is to decode the binary data contained in a South Africa drivers license barcode into a usable JSON format. The decode script must be implemented in JavaScript, and must be able to run in a modern browser.

The goal is to have a function we can use for our mobile application, but for the purpose of this project it can run in a browser page or node script.

For this project we assume that the scanning and decryption of the raw barcode has already been performed.

The (partial) specification of the format is in SPEC.md.

Input / output

The input will be the decrypted barcode data. You may specify the input as base64-encoded string, ArrayBuffer, or a file, but using ArrayBuffer / typed arrays is recommended.

The output should be in JSON, as follows:

{
    "idNumber": "8609135139012",
    "idNumberType": "02",
    "idCountryOfIssue": "ZA",
    "surname": "SANDERS",
    "gender": "01", // '01' = male, '02' = female
    "initials": "J",
    "birthDate": "1986-09-13", // YYYY-MM-DD
    "driverRestrictions": "10",  // "00" / "10" / "20" / "12"
    "licenseCountryOfIssue": "ZA",
    "licenseIssueNumber": "01",
    "licenseNumber": "6234560001AB",
    "licenseValidityStart": "2012-11-14", // YYYY-MM-DD
    "licenseValidityExpiry": "2017-12-14", // YYYY-MM-DD
    "professionalDrivingPermitExpiry": null, // YYYY-MM-DD
    "professionalDrivingPermitCodes": [ // Array of string codes, or null
        "G",
        "P"
    ],
    "vehicleLicenses": [
        {
        "code": "B",
        "restriction": "0",
        "firstIssueDate": "2007-02-19"
        }
    ]
}

Any info not present in the output may be ignored when parsing the input (for example the image in section 3).

Restrictions

The decoding must happen in pure JavaScript. No server-side processing or native Node extensions may be used.

Third-party libraries may be used, but avoid needlessly increasing the code size.

Sample data

A sample license is in license-sample.raw and license-sample.base64. The expected output for this license is in license-sample-parsed.json.

Note that this sample does not cover all cases, for example professional driving permits.

Other notes

While it is not a requirement to run the function in NodeJS, it may simplify testing.

sa-license-decoder's People

Contributors

ugommirikwe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.