Can You Put Resident Registration Numbers in a Test Database? Keep the Format, Change the Value
· DataMint · 7 min read
No. Real resident registration numbers should not be kept in a test database. (The resident registration number, or RRN, is Korea's national ID number, and this post is about Korea.) But if the next question is "so should we empty the RRN column or fill it with asterisks," that is not the answer either. Replace each number with a value that looks like an RRN but is not that person's number. This post is about how to do that.
Why not
The RRN is handled separately even among personal data. Article 24-2 of Korea's Personal Information Protection Act (PIPA) (in Korean) provides that RRNs cannot be processed except in the set exceptions, such as where a statute specifically requires or permits it. Even where processing is allowed, the numbers must be stored encrypted so that they do not leak.
A production system holds RRNs because that business has a legal basis. It is hard to say that the same basis also covers a developer using the same numbers for screen tests. There is a practical problem as well. Numbers that were encrypted in the production database are often decrypted into plain text on the way into the test database. The value that should be handled most strictly ends up in plain text in the loosest place.
An RRN also cannot be changed. If a password leaks you change it, but an RRN in effect lasts a lifetime. Once it is out, that is it.
What happens when you mask with asterisks
The most common response is to hide the second half: 900101-*******. It is a good way to display the number on a screen, but as test data it gets stuck in many places.
| Situation | Result |
|---|---|
| Edit and save customer information on a screen | Rejected by format validation |
| Test sending a message to an external institution | Specification error, characters in numeric positions |
| Look up a customer by RRN | Everyone born on the same day is returned |
| Table with a unique key on the RRN | Load fails on duplicates |
| Verify statistics by gender and age group | Cannot be computed, the gender digit is gone |
| Store in a numeric column | Asterisks cannot be inserted |
Filling everything with 0000000 or 1111111 runs into the same problems, because a value that should differ for each person becomes the same.
The structure of an RRN
To replace the number properly you need to know its structure. The thirteen digits break down like this.
| Position | Content | Example |
|---|---|---|
| 1-6 | Date of birth (YYMMDD) | 900101 |
| 7 | Gender and century of birth (1, 2: 1900s; 3, 4: 2000s; 5-8: foreign nationals) | 1 |
| 8-13 | The remaining six digits | 234568 |
In the past, the digits from position 8 held the code of the region where the birth was registered and a sequence number, and the last digit, position 13, was a check digit calculated from the first twelve. For numbers newly issued or changed since October 2020, the six digits after the gender digit are random. So some recent numbers do not satisfy the old check formula.
Keeping the format and changing only the value
For the replaced number to be useful in testing, it has to meet the following.
Decide whether to keep the birth date and gender
If you keep the first seven digits, business logic that branches on age and gender (restrictions for minors, products by age group, insurance premium calculation) can be tested the same way as in production. In exchange, the birth date and gender remain as in the original. These alone rarely identify a person, but combined with a name and address they narrow things down. So the name and address have to be replaced as well, and if you need to be stricter, the birth date can also be shifted within a range of a few days. Which is right depends on the purpose of the test.
Different digits in the second half, different for each person
If two different people end up with the same number, unique keys break. If the originals differ, the results must differ. With random picks, when the volume is large you get colliding numbers within the same birth date and gender. The method has to map one to one.
The same number becomes the same number everywhere
The same person's number has to become the same value in the customer table, the contract table, and the databases of other systems for joins and interfaces to line up.
Not traceable back
A rule like "multiply the second half by 7" is fully broken as soon as someone knows one person's original and result. Calculate with a secret key, and keep that key outside the test environment.
| Resident registration number | Note | |
|---|---|---|
| Production | 900101-1234568 | |
| Asterisks | 900101-******* | Format broken, many identical values |
| Converted | 900101-1947305 | Birth date and gender kept, different for each person |
Other things to take care of
- There are several notations. With a hyphen, without one, and with the two halves split across separate columns, all mixed within one system. The same number has to become the same value even when the notation differs.
- The numbers are in places that are not RRN columns. They are written in support memos, remarks, and interface messages. See personal data in memos.
- Alien registration numbers (issued to foreign residents) have the same thirteen-digit structure. They are often mixed into the same column.
- Encrypted columns have to be decrypted before conversion, and if the test system expects encrypted values, encrypted again after conversion. Make sure no plain text is left in files along the way.
- Some columns are derived from the number. In tables that keep the birth date, gender or age in separate columns, the number and the derived columns have to agree.
RRN conversion in DataMint Core
DataMint Core replaces an RRN with a different number in the shape of an RRN. It calculates with a secret key that differs for each customer, so no mapping table is stored, and the same number becomes the same value even across different tables and databases. Conversion happens while the data is being read from the production database and moved, so only converted numbers ever enter the test database.

RRNs written inside long text such as support memos are converted to the same value as in the column. The number in the customer table and the number written in that customer's memo still match in the test database.
Closing
Keeping real RRNs out of the test database and giving up on tests that need RRNs are two different things. Keep the format and birth date, make the value different for each person, the same everywhere, and not traceable back, and you get both. The place to start is counting how many plain-text RRNs are in your test database right now.
If you first need to find which columns hold them, see how to find personal data columns.
- #resident registration number masking
- #national ID in test data
- #format-preserving transformation
- #test data
- #PIPA Korea
- #RRN