Identification

A suite of tools for working with various identity documents. Allows verification of Passports and (coming very soon) UK Drivers Licenses. Generation tools coming soon.

Examples

Create a Passport instance with an MRZ Code.

passport = Identification::Passport.new mrz_line_1: "mrz_line_1", mrz_line_2: "mrz_line_2"

and you're done! Use it like this:

passport.valid?
# => true
passport.last_name
# => LAST
passport.gender
# => M

Installation

Add this line to your application's Gemfile:

gem 'identification'

And then execute:

$ bundle

Or install it yourself as:

$ gem install identification

Usage

Passport

Setup your passport instance like so:

passport = Identification::Passport.new mrz_line_1: "mrz_line_1", mrz_line_1: "mrz_line_2"
mrz_line_1: The first line of a Passport MRZ (the long strip of text on the bottom). (string)
mrz_line_2: The second line of a Passport MRZ (the long strip of text on the bottom). (string)

It then can be called using any of the folllowing methods/accessors:

valid? : Returns true if it's a valid passport MRZ, false if it's not.
issuing_state : Issuing country of the passport
last_name : Last name on the passport
first_names : Array of first names on the passport (First and any middle names)
passport_number : Passport Number
nationality : Nationality of the person on the passport. Different from the issuing state (eg. Swedish person who is also a citizen of UK.)
date_of_birth : Date of Birth, given as a Ruby Date object.
gender : Gender, given as M, F or nil if not specified.
expiry_date : Expiry date of the passport, given as a Ruby Date object.
personal_number : Personal number, if chosen to be given by issuer. Nil if not specified.

UK Drivers License

Note: This does not verify check digits yet. I am currently in a 'legal argument' with the DVLA over whether it is in the public interest to release the check digit algorith as they're claiming it is a security threat... Feel free to follow the FOI request on WhatDoTheyKnow and I'll update the gem once I have a response.

Setup your UK Drivers License (DVLA issued only) instance like so:

ukdl = Identification::DVLA.new driver_number: "your_driver_number"
driver_number: driver number from Section 5 of a license, 16 or 18 digit (if 16 digit license_numbers will be set to 00) (string)

It then can be called using any of the folllowing methods/accessors:

valid? : Returns true if it's a valid UK drivers license number, false if it's not.
last_name : First 5 letters of the last name of the license holder
first_initials : First initial(s) of the license holder
date_of_birth : Date of Birth, given as a Ruby Date object.
gender : Gender, given as M, F or nil if not specified.
license_numbers : License number (2 digit number at end of section 5)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install the gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are more than welcome on GitHub at https://github.com/rubymeow/identification! <3

License

The gem is available as open source under the terms of the MIT License.

MRZ parsing based on Document 9303 (Machine Readable Travel Documents - Part 1 - Machine Readable Passports. Volume 1 - Passports with Machine Readable Data Stored in Optical Character Recognition format) by the ICAO which can be found here: http://www.icao.int/publications/pages/publication.aspx?docnum=9303

Warning: This is by no means a KYC solution on it's own. This merely parses and validates numbers/codes with their given algorithms to make sure they're not an edited forgery. It's not difficult to circumvent this, and this should only be used to validate input or expedite information checking.