Masking format is a combination of change method and displayed characters when the masking condition is met. Masking format varies depending on the masking type. The following describes the masking format.
Full masking
With full masking, all characters are changed to values as determined by the database. Changed characters can be referenced in the pgx_confidential_values table. Also, replacement characters can be changed using the pgx_update_confidential_values system management function.
See
Refer to "8.3 Data Types for Masking" for information on the data types for which data masking can be performed.
Partial masking
With partial masking, data is changed according to the content in the function_parameters parameter. The method of specifying function_parameters varies depending on the data type.
Category | Method of specifying function_parameters |
---|---|
Numeric type | 'replacementCharacter, startPosition, endPosition'
Example Specify as below to change the values from the 1st to 5th digits to 9. function_parameters := '9, 1, 5' In this example, if the original data is "123456789", it will be changed to "999996789". |
Character type | 'inputFormat, outputFormat, replacementCharacter, startPosition, endPosition'
Example Specify as below to mask a telephone number other than the first three digits using *. function_parameters := 'VVVFVVVVFVVVV, VVV-VVVV-VVVV, *, 4, 11' In this example, if the original data is "012-3156-7890", it will be changed to "012-****-****". |
Date/timestamp type | 'MDYHMS'
Example Specify as below to mask hour, minute, and second and display 00:00:00. function_parameters := 'MDYh0m0s0' In this example, if the original data is "2022-02-10 10:10:10", it will be changed to "2022-02-10 00:00:00". |
See
Refer to "B.4.2 pgx_create_confidential_policy" for information on function_parameters.
Refer to "8.3 Data Types for Masking" for information on the data types for which masking can be performed.
Regular expression masking
With regular expression masking, data is changed according to the content of the regexp_pattern, regexp_replacement and regexp_flags parameters. For regexp_pattern, specify the search pattern using a regular expression. For regexp_replacement, specify the replacement character to use when data matches the search pattern. For regexp_flags, specify the regular expression flags.
Example
Specify as below to change all three characters starting from b to X.
regexp_pattern := 'b..'
regexp_replacement:= 'X'
regexp_flags := 'g'
In this example, if the original data is "foobarbaz", it will be changed to "fooXX".
See
Refer to "POSIX Regular Expressions" in the PostgreSQL Documentation and check pattern, replacement, and flags for information on the values that can be specified for regexp_pattern, regexp_replacement, and regexp_flags.
Refer to "8.3 Data Types for Masking" for information on the data types for which masking can be performed.
Note
When column data type is character(n) or char(n) and if the string length after change exceeds n, the extra characters will be truncated and only characters up to the nth character will be displayed.
When column data type is character varying(n) or varchar(n) and if the string length after change exceeds the length before the change, the extra characters will be truncated and only characters up to the length before change will be displayed.