Coder Social home page Coder Social logo

vishaltanwar96 / aadhaar-py Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 1.0 145 KB

This library helps you extract the embedded information in Aadhaar Secure QR Code

Home Page: https://pypi.org/project/aadhaar-py/

License: MIT License

Python 100.00%
aadhaar qrcode decoder secure-qr aadhaar-secure-qr extract extractor

aadhaar-py's Introduction

aadhaar-py ๐Ÿ

made-with-python PyPI pyversions PyPI version MIT license Code style: black codecov Downloads

This library helps you extract the embedded information ๐Ÿ’พ in Aadhaar Secure QR Code

Inspired from ๐Ÿ˜‡

I would like to thank the authors of pyaadhaar. It wouldn't be possible to move into the right direction without this library.

Demo โœ”๏ธ

Secure Aadhaar QR Decoder

Enough talk, show me how it works! โœจ

>>> from aadhaar.secure_qr import extract_data
>>> received_qr_code_data = 12345678
>>> extracted_data = extract_data(received_qr_code_data)

The extract_data function returns an instance of ExtractedSecureQRData which has the definition of:

@dataclass(frozen=True)
class ExtractedSecureQRData:
    text_data: ExtractedTextData
    image: Image.Image
    contact_info: ContactData

Text Data ๐Ÿ“:

>>> extracted_data.text_data
ExtractedTextData(reference_id=ReferenceId(last_four_aadhaar_digits='8908', timestamp=datetime.datetime(2019, 3, 5, 15, 1, 37, 123000)), name='Penumarthi Venkat', date_of_birth=datetime.date(1987, 5, 7), gender=<Gender.MALE: 'Male'>, address=Address(care_of='S/O: Pattabhi Rama Rao', district='East Godavari', landmark='Near Siva Temple', house='4-83', location='Sctor-2', pin_code='533016', post_office='Aratlakatta', state='Andhra Pradesh', street='Main Road', sub_district='Karapa', vtc='Aratlakatta'))

The Embedded Image ๐ŸŒ†:

>>> extracted_data.image
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=60x60 at 0x1029CA460>

The Contact Information ๐Ÿ“ง:

>>> extracted_data.contact_info
ContactData(email=Email(hex_string=None, fourth_aadhaar_digit='8'), mobile=Mobile(hex_string='1f31f19afc2bacbd8afb84526ae4da184a2727e8c2b1b6b9a81e4dc6b74d692a', fourth_aadhaar_digit='8'))

But hey! ๐Ÿ™„ I want to send this data via a ReSTful API, don't you have something to serialize that ugly instance of ExtractedSecureQRData? ๐Ÿ˜ฉ

to_dict method to the rescue ๐Ÿ’ช

>>> extracted_data.to_dict()
{
  "text_data": {
    "reference_id": {
      "last_four_aadhaar_digits": "8908",
      "timestamp": "2019-03-05T15:01:37.123000"
    },
    "name": "Penumarthi Venkat",
    "date_of_birth": "1987-05-07",
    "gender": "Male",
    "address": {
      "care_of": "S/O: Pattabhi Rama Rao",
      "district": "East Godavari",
      "landmark": "Near Siva Temple",
      "house": "4-83",
      "location": "Sctor-2",
      "pin_code": "533016",
      "post_office": "Aratlakatta",
      "state": "Andhra Pradesh",
      "street": "Main Road",
      "sub_district": "Karapa",
      "vtc": "Aratlakatta"
    }
  },
  "image": "data:image/jpeg;base64,/9j/4AAQSkZblahblah",
  "contact_info": {
    "email": {
      "hex_string": None
    },
    "mobile": {
      "hex_string": "1f31f19afc2bacbd8afb84526ae4da184a2727e8c2b1b6b9a81e4dc6b74d692a"
    }
  }
}

Run Tests ๐Ÿงช

python -m unittest discover tests/ --verbose

aadhaar-py's People

Contributors

dependabot[bot] avatar vishaltanwar96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

eshwar-gatram

aadhaar-py's Issues

Fix the Demo Application

Maybe an API based Approach and using a React based Frontend or Simply revamping the old code.

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.