Giter Site home page Giter Site logo

afilini / cie-mrtd-python-sdk Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 72 KB

Libreria leggera e portabile in Python per l'estrazione delle informazioni contenute nella CIE 3.0, con e senza autenticazione EAC.

License: BSD 3-Clause "New" or "Revised" License

Python 99.70% Shell 0.30%
hackathon hackdev17 cie italia mrz opencv nfc python

cie-mrtd-python-sdk's Introduction

Python CIE3 SDK Build Status

Libreria leggera e portabile in Python per l'estrazione delle informazioni contenute nella CIE 3.0, con e senza autenticazione EAC.

Installazione

Per iniziare installa tutte le dipendenze tramite il gestore di pacchetti pip, con il comando:

pip install -r requirements.txt

Esempio

Il file main.py contiene un brevissimo esempio che mostra l'estrazione dei dati dalla CIE tramite autenticazione EAC.

Struttura

L'intera libreria è strutturata attorno alla classe CIEInterface che espone molti metodi utili per inviare comandi alla CIE.

Al momento della creazione di un'istanza di CIEInterface, il costruttore tenterà di aprire una connessione con un lettore NFC compatibile e si metterà in attesa di rilevare una carta. Il massimo tempo di attesa è attualmente di 3 secondi.

Una volta rilevata la carta il costruttore termina l'esecuzione.

I metodi a disposizione dell'utilizzatore sono i seguenti:

  • CIEInterface.readNIS(): Legge la sezione EF.ID_Servizi della carta, ovvero l'id univoco della carta.
  • CIEInterface.randomNumber(): Invia un APDU alla carta chiedendo al microprocessore di generare un numero casuale.
  • CIEInterface.mrtdAuth(birthStr, expireStr, pnStr): esegue l'autenticazione tramite i dati contenuti nell'MRZ, per poter accedere alle informazioni aggiuntive presenti sulla carta. I parametri sono stringhe, nel caso delle date in formato YYMMDD, mentre pnStr è semplicemente il numero della CIE.
  • CIEInterface.extractData(): estrae i dati aggiuntivi disponibili dopo l'unlock della carta. A secodna delle informazioni disponibili vengono estratti:
    • mrz: Stringa identica all'MRZ stampato sulla carta
    • additional_details: Informazioni aggiuntive sul cittadino, come ad esempio l'indirizzo di residenza
    • photo: bytearray contenete l'immagine in formato JPEG2000. Per comodità l'immagine viene anche salvata su disco nel file img.jpeg.

Supporto

La libreria è stata testata con successo su Python 2.7.14 su sistema macOS, ma vista la semplicità è molto probabile che funzioni nativamente anche su altre versioni.

cie-mrtd-python-sdk's People

Contributors

afilini avatar danielabrozzoni avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ndr-brt

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.