Portuguese Citizen Card Validator
Validate 12-character Portuguese Cartão de Cidadão numbers in real time.
Portuguese Cartão de Cidadão Validation
Validates the 12-character format (NNNNNNNN C XX Y) using the official alphanumeric Luhn mod 10 checksum algorithm.
Ensures compliance for Portuguese user onboarding and identity verification software.
Anatomy & Structure of Portuguese Citizen Card
The Citizen Card document number comprises 12 characters across 4 functional blocks:
| Position | Field | Length | Meaning & Rule | Example |
|---|---|---|---|---|
| 1 to 8 | Civil ID (NIC) | 8 digits | National Civil ID number, zero-padded if necessary | 12345678 |
| 9 | NIC Check Digit | 1 digit | Mathematical checksum of the Civil ID component | 9 |
| 10 & 11 | Version Code | 2 chars | Alphanumeric document physical issuance version code | ZZ |
| 12 | Overall Check Digit | 1 char | Global document checksum computed via base-36 Luhn algorithm | 4 |
Citizen Card Validation Algorithm (Luhn in Base 36)
The official IRN/AMA algorithm evaluates all 12 characters right-to-left in base 36:
sum(double_or_direct(Base36(char_i))) % 10 == 0
- 1. Map each character to base-36 value: digits 0-9 retain value; letters A-Z map to 10-35 (ASCII - 55).
- 2. Processing right-to-left (i=0 to 11), double values at odd positions (1, 3, 5, 7, 9, 11).
- 3. If doubled value exceeds 9, subtract 9 from it.
- 4. Keep direct values at even positions (0, 2, 4, 6, 8, 10).
- 5. Sum all components: document is valid if the grand total is evenly divisible by 10 (sum % 10 == 0).