[South African Specific]

### SAIDValidator Webservice

SAIDValidator is an ASP.NET webservice to validate South African Person ID numbers. It provides validation of a person ID by calculating the check-digit (digit-13), and extracts the date-of-birth, gender, citizenship, sequence and other information. The following links are available:

- SAIDValidator Homepage
- SAIDValidator Test Page : Input an ID number and see if it is valid!
- SAIDValidator Webservice

### South African Department of Home Affairs

If you would like to check your SA Passport or ID application status, or your current official marital status, please click on the link below:

- Enquiry on ID, Passport and Marital Status

### How to validate SA Identity Numbers

An enigmatic quest indeed, with no definitive standards published by any SA government department known. The following blogs show the basics for validating SA Identity numbers:

- http://www.vanjaarsveld.com/default.aspx
- http://codingsanity.blogspot.com/2004/10/id-validation.html
- http://www.powertrip.co.za/blog/archives/000007.html
- http://www.powertrip.co.za/blog/archives/000135.html

Here’s my interpretation and short code-excerpt for validating ‘digit-13’, the so-called ‘check’ digit:

Format:

{YYMMDD}{G}{SSS}{C}{A}{Z}

YYMMDD : Date of birth.

G : Gender. 0-4 Female; 5-9 Male.

SSS : Sequence No. for DOB/G combination.

C : Citizenship. 0 SA; 1 Other.

A : Usually 8, or 9 [can be other values]

Z : Control digit calculated in the following section:

Formula to calculate the check digit for a 13 digit identity number:

According to the provisions of the Identification Amendment Act, 2000 (Act No. 28 of 2000,

which was promulgated on 13 October 2000) all forms of identity documents other than the

green bar-coded identity document are invalid. [my observation: the following algorithm appears to work for the older ‘blue’-book id numbers as well]. In accordance with the legislation,

the control figure which is the 13th digit of all identity numbers which have 08 and 09 is

calculated as follows using ID Number 800101 5009 087 as an example:

- Add all the digits in the odd positions (excluding last digit).

8 + 0 + 0 + 5 + 0 + 0 = 13……………….[1] - Move the even positions into a field and multiply the number by 2.

011098 x 2 = 22196 - Add the digits of the result in b).

2 + 2 + 1 + 9 + 6 = 20…………………….[2] - Add the answer in [2] to the answer in [1].

13 + 20 = 33 - Subtract the second digit (i.e. 3) from 10. The number must tally with the last number in the ID Number. If the result is 2 digits, the last digit is used to compare against the last number in the ID Number. If the answer differs, the ID number is invalid.

Here’s the digit-13 check C# code

[Check below for a validator using a working version of this code]:

```
// This method assumes that the 13-digit id number has
// valid digits in position 0 through 12.
// Stored in a property 'ParseIdString'.
// Returns: the valid digit between 0 and 9, or
// -1 if the method fails.
private
int GetControlDigit() {
int d = -1;
try {
int a = 0;
for (int i = 0; i < 6; i++) {
a += int.Parse(this.ParsedIdString[2 * i].ToString());
}
int b = 0;
for (int i = 0; i < 6; i++) {
b = b * 10 + int.Parse(this.ParsedIdString[2 * i + 1].ToString());
}
b *= 2;
int c = 0;
do {
c += b % 10;
b = b / 10;
} while (b > 0);
c += a;
d = 10 - (c % 10);
if (d == 10) d = 0;
} catch { /*ignore*/
}
return d;
}
```