Skip to main content

Extract embedded information from Aadhaar Secure QR Code.

Project description

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

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

aadhaar-py-2.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aadhaar_py-2.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file aadhaar-py-2.0.0.tar.gz.

File metadata

  • Download URL: aadhaar-py-2.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.9 Linux/5.11.0-1022-azure

File hashes

Hashes for aadhaar-py-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4b1b57b1044c34b12e6dfcd56c4897c88a6828138af90662e90a6cad80fcd989
MD5 230add5f50e063b28e92ed6114dfc5c3
BLAKE2b-256 6536cd63114b0de3408360a9f9fcf16b8ffbfec40f22349e19d0bd87d49d7f71

See more details on using hashes here.

File details

Details for the file aadhaar_py-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: aadhaar_py-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.9 Linux/5.11.0-1022-azure

File hashes

Hashes for aadhaar_py-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22f00d5ced096e3e9156be367d9f97dc4c309668fa23abe344843f90d1301bf3
MD5 eae1f8e20f6e6a16dd8b1bc860357bf8
BLAKE2b-256 660ba3c49e8b1a695fc9a330ee44671ac1b23d460639d64b27b8e36f2b2f9b7d

See more details on using hashes here.

Supported by

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