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.

Testing with data whose second half was replaced with asterisks
SituationResult
Edit and save customer information on a screenRejected by format validation
Test sending a message to an external institutionSpecification error, characters in numeric positions
Look up a customer by RRNEveryone born on the same day is returned
Table with a unique key on the RRNLoad fails on duplicates
Verify statistics by gender and age groupCannot be computed, the gender digit is gone
Store in a numeric columnAsterisks 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.

The 13 digits of a resident registration number
PositionContentExample
1-6Date of birth (YYMMDD)900101
7Gender and century of birth (1, 2: 1900s; 3, 4: 2000s; 5-8: foreign nationals)1
8-13The remaining six digits234568

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.

Before and after
Resident registration numberNote
Production900101-1234568
Asterisks900101-*******Format broken, many identical values
Converted900101-1947305Birth 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.

DataMint Core job creation screen with transformation rules assigned to the RRN, phone number and email columns of a customer table
The product looks at column names and comments and attaches a matching rule to the RRN column first. You can preview the converted result before saving. (The console is shown in Korean. The data on screen is demo data.)

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

Reviewing how you handle test data?

Tell us how you do it today and what databases you run, and we will look at the options with you.

More posts