buildwithrex Follow
All posts

Why the last digit of your Aadhaar number isn't random

The 12th digit is computed from the other 11, so a typo or a swap fails the check. But a passing number isn't proof the Aadhaar exists.

Programming · 15 Nov 2026 · 2 min read

Look at any 12-digit Aadhaar number and it seems like random digits. Eleven of them are. The last one isn't: it's worked out from the other eleven. UIDAI's 2010 paper on the numbering scheme puts it plainly, "12 digits (11 + 1 check sum)", and names the method it chose: the Verhoeff scheme.

What a check digit is for

People mistype numbers. The two most common mistakes are getting one digit wrong and swapping two neighbouring digits. A check digit is an extra digit computed from the rest, so that when someone types the number, the system can recompute it and notice that something is off, before any lookup or payment happens. NPCI's process for linking Aadhaar to bank accounts asks banks to run exactly this Verhoeff check.

Think of a kirana bill. If one price is written wrong, the total stops matching. But if two prices swap lines, a plain total still matches, and the mistake hides. A simple sum of digits has the same weakness.

Luhn vs Verhoeff

Card numbers use the Luhn check from 1960. It catches every single wrong digit, but some swaps slip through: 09 and 90 give the same Luhn result. Verhoeff's 1969 scheme fixes this by transforming each digit according to its position before combining them, using a small multiplication table from the dihedral group D5. The result catches every single-digit error and every swap of two neighbouring digits. In our lab, across 10,000 random numbers, Luhn missed 2,143 neighbour swaps and Verhoeff missed none.

What it can't tell you

A check digit only says "no typo found". Any eleven digits have exactly one valid last digit, so about 1 in 10 random 12-digit strings pass. UIDAI has warned that "all 12-digit numbers are not Aadhaar". Whether a number was actually issued is something only UIDAI's verification can confirm.

And because Aadhaar numbers aren't meant to be published, the reel and the lab use a made-up demo number. Never post yours in a comment.

The answer to give

A check digit is computed from the other digits to catch typos at entry. Luhn misses some neighbour swaps; Verhoeff catches all single errors and all neighbour swaps. Neither proves a number is real.

Sources: UIDAI "A UID Numbering Scheme" (2010), as quoted; UIDAI, Features of Aadhaar; Verhoeff (1969); NPCI APB SOP; UIDAI warning, July 2021.