Your CURP is not random: 18 characters that spell out your birthdate, sex and birthplace

2026-12-05来源 dev.toEnglish

Every Mexican has one. It is printed on your INE, your birth certificate, your payroll records, every government form you have ever filled in. Eighteen characters, letters and digits mixed together, and it looks like someone smashed a keyboard.

It is not random. Read it left to right and it tells a small story about you: your initials, the day you were born, whether you are recorded as a man or a woman, and the state where you were born. The last character is a check digit, computed from the other seventeen, so a typo announces itself before it reaches a database.

Reading a CURP like a sentence

Take BOXW310820HNERXN09, a real-format example:

  • Characters 1 to 4: initials. B is the first letter of the paternal surname, O its first internal vowel, X stands in for a missing maternal surname, and W is the first letter of the given name.
  • Characters 5 to 10: the birthdate as YYMMDD. 31 08 20 is 20 August 1931.
  • Character 11: sex. H for hombre, M for mujer. Newer CURPs can carry X for non-binary people.
  • Characters 12 and 13: the state of birth. NE means Nacido en el Extranjero, born abroad. DF is the legacy code for Distrito Federal, now CM for Ciudad de Mexico.
  • Characters 14 to 16: the internal consonants of the two surnames and the given name.
  • Character 17: the generation marker. A digit 0 to 9 means born in the 1900s, a letter A to Z means born in the 2000s. That is how the two-digit year stays unambiguous: 31 could be 1931 or 2031, and the marker settles it.
  • Character 18: the check digit.

So BOXW310820HNERXN09 decodes to: a man, born 20 August 1931 outside Mexico, whose surnames and name start with B, O and W. Nothing else about him is in there. The number carries no address, no phone, no job. It is an identity key, not a biography.

One more example, from the 2000s generation: SABC020626MDFLRNA3 is a woman born 26 June 2002 in Distrito Federal. The A at position 17 is the giveaway that she belongs to the 2000s, not the 1900s.

The check digit

The last character is computed from the first seventeen with a weighted sum. Each character has a value in a fixed 37-character alphabet: digits keep their value, A is 10, B is 11, all the way through N at 23, then Ñ at 24, O at 25, up to Z at 36. Multiply the first character by 18, the second by 17, and so on down to 2, add everything up, and the check digit is what brings the total up to the next multiple of 10.

For BOXW310820HNERXN0 the working looks like this:

const ALPHABET = "0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"; function curpCheckDigit(first17) { let sum = 0; for (let i = 0; i < 17; i++) { sum += ALPHABET.indexOf(first17[i]) * (18 - i); } return (10 - (sum % 10)) % 10; } curpCheckDigit("BOXW310820HNERXN0"); // 9 

The individual products are 198, 425, 544, 495, 42, 13, 0, 88, 20, 0, 136, 161, 84, 140, 136, 69 and 0. They add up to 2551. 2551 ends in 1, and 10 minus 1 is 9, which is exactly the last digit of the CURP. Valid.

Change one digit and it breaks. BOXW310820HNERXN08 ends in 8, but the math still says 9, so the number is rejected. That is the whole point: a single mistyped digit, and most swaps of two neighbouring digits, make the check digit disagree. The error is caught before it reaches a form, a payroll file, or a government portal.

Here is the complete validator in about fifteen lines:

const ALPHABET = "0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"; function isValidCurp(curp) { const clean = curp.toUpperCase().replace(/[^0-9A-ZÑ]/g, ""); if (clean.length !== 18) return false; let sum = 0; for (let i = 0; i < 17; i++) { sum += ALPHABET.indexOf(clean[i]) * (18 - i); } return (10 - (sum % 10)) % 10 === Number(clean[17]); } isValidCurp("BOXW310820HNERXN09"); // true (sum 2551, check 9) isValidCurp("GODE561231MDFRRN00"); // true (sum 2030, check 0) isValidCurp("SABC020626MDFLRNA3"); // true (sum 1877, check 3) isValidCurp("BOXW310820HNERXN08"); // false (check should be 9) 

Two details worth noticing. First, Ñ has its own value in the alphabet, 24, sitting between N at 23 and O at 25. Leave it out and every CURP containing Ñ validates wrong. Second, the (10 - x) % 10 at the end handles the case where the sum already ends in 0, in which case the check digit is 0, not 10. GODE561231MDFRRN00 is that case: its products add up to 2030, so the check digit is 0.

The polite X

There is one human touch in the system. The first four letters of a CURP are initials, and initials sometimes spell an unfortunate word. RENAPO's rule is simple: when the four letters form an offensive word, the second letter is replaced with X. That is why some CURPs carry an X in second position that has nothing to do with a missing surname. It is a small piece of decency baked into an identity standard, and it is the reason a validator should never "correct" an X in that spot back into a vowel.

What the check cannot do

A valid check digit proves the number is well formed. It does not prove the person exists, that the CURP is registered with RENAPO, or that it belongs to the person in front of you. Only RENAPO's own lookup can confirm that, and it needs a captcha and a reason to ask. A random 18-character string passes the check about 1 time in 10 by luck, because any check digit has a 1 in 10 chance of matching. Treat a pass as "worth typing into the official portal", never as proof of identity.

The CURP is also personal data, protected by Mexican law. Only check a CURP you are entitled to handle, and never paste someone else's into a site you do not trust. The check itself is pure arithmetic, so it can run entirely in your browser with nothing uploaded, which is how a validator should work for data this sensitive.

The same trick is everywhere

Once you see the pattern, you start spotting it in every identifier you type. A Mexican CLABE uses weights 3, 7 and 1 over 17 digits. A US routing number uses the same 3-7-1 weights over 9 digits. A credit card number uses the Luhn algorithm. An ISBN-13 uses alternating 1 and 3 weights. They are all the same idea: a little redundancy, placed where a human is most likely to slip, so the error announces itself instead of silently costing time.

If you work with Mexican payroll, onboarding, or any form that asks for a CURP, run the check before you submit anything. It is fifteen lines, it runs entirely in the browser, and it catches the most common failure mode of all: a tired human typing 18 characters by hand.

I built a free validator that does exactly this, with the birthdate, sex and state decoded and the step-by-step working shown so you can see every value and weight: https://www.theutilityhub.online/tools/curp-validator

Paste a CURP, see whether it is valid, what it decodes to, and what the check digit should have been. If you only have 17 characters, it computes the 18th for you.

原文:https://www.a8q9.cn/en/article/your-curp-is-not-random-18-characters-that-spell-out-your-birthdate-sex-and-birt-df8566.html

相关文章