The meaning behind Taiwan ID numbers

2 is female.
1 is male.
If you are inputting 2 but it asks you if you are male or female, it might fail or be recognised as false.

Awesome, thank you!

That’s the magic of open source and people that care :heart_eyes:

I used it as a starting point to write this:

https://jsfiddle.net/Lw3jh8v7/

I will make a basic page that lets users check id numbers.

1 Like

I figured it out with the help of the library that @fifieldt posted. Most implementations are quite bad. It is hard to get the mathematical method from them about how the checksum is calculated. Especially in cases of ARC gender encoding, since most implementations ignore them.

The answer to my question is:

Each letter has a specific value. You use that value to calculate a weighted sum and from there you calculate the checksum digit.
So if it is an ARC then you calculate weighted sum from the letter value otherwise you just calculate it from the numeric value.

2 Likes

I made a page to verify Taiwan IDs. It will also display the information contained in the number.
The ID is checked with JavaScript and not transferred/saved anywhere.

Verify Taiwan ID

I also wrote down how to implement it. Will add some time later code examples on github.

You can also generate valid ID number just by typing something up and it will tell you the correct check digit if you got it wrong.

You can test it with A123456789 if you don’t want to use your own ID. That poor guy. :grin:

example_id

5 Likes

Hi, I am curious about how to validate the ARC number. I saw a previous post that touched a similar subject (the national id number), but I am still unclear on how ARC works. I assumed it’s similar.
So the second char. is A-D. regularly, 1 is males and 2 is female. A/C is for males and B/D females. If I try converting these to 1 or 2 the check digit does not work out for me.
Example - TD00251124 (validated here: 🆔 Verify Taiwan ID | Project | slawa.dev ). Converting D to either 1 or 2 is incorrect.
So, how do you validate an ARC number?

1 Like

https://identity.tw

Look at the code examples.


The check digit is a weighted sum of the digits, modulo 10, with different weights for each number position.

Letters

The first character (and sometimes the second) are not numeric and the summand of the weighted sum is calculated differently. The letters have a specific value assigned to them.

A=10, B=11, C=12, D=13, ...

The easiest way to implement this is to get the index of the letter in the following string and add 10 to it. You will get the assigned number.

var letters = "ABCDEFGHJKLMNPQRSTUVXYWZIO";

Letters I and O (which could be interpreted as 1 and 0) were pushed back to the end of the alphabet in an attempt to avoid them. Letter Z also has been shifted.

3 Likes