If you are working on such application where you have to authenticate Aadhaar number entered by the user you may want to validate it using any standard algorithm before sending it to UIDAI server to get auth response. Before learning how to write code using Verhoeff algorithm let us understand about the structure of Aadhaar number issued by UIDAI(Unique Identification Authority of India).

#### Structure of Aadhaar Number :

The Aadhaar number has 12 digits numbers only where the first 11 digits are random numbers and the twelfth digit is a checksum (by using the Verhoeff algorithm) of the preceding 11 digits.

[su_note note_color=”#fdf6d5″]UIDAI has recommended Verhoeff algorithm for validating the same. Based on the same, component has been developed to validate the Aadhaar number entered in an application. [/su_note]

#### How to write code using Verhoeff algorithm :

The Verhoeff algorithm is basically a checksum formula for error detection which was first published in 1960 and developed by the Dutch mathematician Jacobus Verhoeff. It was the first decimal check digit algorithm which detects all single-digit errors, and all transposition errors involving two adjacent digits, which was at the time thought impossible with such a code.

For more info, you can navigate this link – https://en.wikipedia.org/wiki/Verhoeff_algorithm

[su_note note_color=”#fdf6d5″]The Verhoeff algorithm can be implemented using three tables: a multiplication table d, an inverse table inv, and a permutation table p.[/su_note]

- Multiplication Table D. The first table,
, is based on multiplication in the dihedral group D*d*_{5} - The inverse table
represents the multiplicative inverse of a digit.**inv** - The permutation table
applies a permutation to each digit based on its position in the number.**p**

[su_box title=”Note:” box_color=”#faf62b” title_color=”#151111″]While working with Aadhaar number validation using Verhoeff, you should remember that this is just an algorithm which is used to validate checksum of 11 digits of Aadhaar number. [/su_box]

When you try to understand the above code, you can easily understand this is not tough to bypass the algorithm if somebody actually knows how to find out checksum of the last 11 digits of their Aadhaar number. The sole purpose to use the Verhoeff algorithm to avoid silly data entry errors before sending it to the UIDAI server for real-time authentication.

## Leave a Reply