Validating UIDAI Aadhaar number using Verhoeff Algorithm

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.

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.

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 –

The Verhoeff algorithm can be implemented using three tables: a multiplication table d, an inverse table inv, and a permutation table p.

  1. Multiplication Table D. The first table, d, is based on multiplication in the dihedral group D5
  2. The inverse table inv represents the multiplicative inverse of a digit.
  3. The permutation table p applies a permutation to each digit based on its position in the number.
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.

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.

About Ravi Ranjan Kumar 30 Articles
An Indian who Living, Loving & Learning Technology with different tastes and willing to share knowledge and thoughts.

Be the first to comment

Leave a Reply