You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/02/01 06:11:47 UTC

[shardingsphere] branch master updated: Revise pr#23685 (#23893)

This is an automated email from the ASF dual-hosted git repository.

zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 9ef4d9825cc Revise pr#23685 (#23893)
9ef4d9825cc is described below

commit 9ef4d9825cc190ee4e6c50dc2b56ac2f199cf3a9
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Wed Feb 1 14:11:39 2023 +0800

    Revise pr#23685 (#23893)
---
 .../common-config/builtin-algorithm/mask.cn.md     | 12 ++---
 .../common-config/builtin-algorithm/mask.en.md     | 12 ++---
 ...thmUtil.java => MaskAlgorithmPropsChecker.java} |  4 +-
 .../cover/KeepFirstNLastMMaskAlgorithm.java        |  8 ++--
 .../algorithm/cover/KeepFromXToYMaskAlgorithm.java |  8 ++--
 .../cover/MaskAfterSpecialCharsAlgorithm.java      |  6 +--
 .../cover/MaskBeforeSpecialCharsAlgorithm.java     |  6 +--
 .../cover/MaskFirstNLastMMaskAlgorithm.java        |  8 ++--
 .../algorithm/cover/MaskFromXToYMaskAlgorithm.java |  8 ++--
 .../GenericTableRandomReplaceAlgorithm.java        | 56 ++++++++++------------
 .../replace/LandlineNumberRandomAlgorithm.java     |  4 +-
 ...litaryIdentityNumberRandomReplaceAlgorithm.java |  4 +-
 ...est.java => MaskAlgorithmPropsCheckerTest.java} | 30 ++++++------
 .../GenericTableRandomReplaceAlgorithmTest.java    |  2 +-
 14 files changed, 82 insertions(+), 86 deletions(-)

diff --git a/docs/document/content/user-manual/common-config/builtin-algorithm/mask.cn.md b/docs/document/content/user-manual/common-config/builtin-algorithm/mask.cn.md
index 2154998d8e6..bb23d1f4f21 100644
--- a/docs/document/content/user-manual/common-config/builtin-algorithm/mask.cn.md
+++ b/docs/document/content/user-manual/common-config/builtin-algorithm/mask.cn.md
@@ -141,12 +141,12 @@ weight = 9
 
 可配置属性:
 
-| *名称*            | *数据类型* | *说明*        |
-|-----------------|----------|-------------|
-| uppercase-letter-codes | String   | 大写字母 |
-| lowercase-letter-codes | String   | 小写字母 |
-| digital-random-codes   | String   | 数字    |
-| special-codes          | String   | 特殊字符 |
+| *名称*                   | *数据类型* | *说明*                                                                   |
+|------------------------|----------|------------------------------------------------------------------------|
+| uppercase-letter-codes | String   | 大写字母码表(以英文逗号分隔,默认值:A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)|
+| lowercase-letter-codes | String   | 小写字母码表(以英文逗号分隔,默认值:a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)|
+| digital-codes          | String   | 数字码表(以英文逗号分隔,默认值:0,1,2,3,4,5,6,7,8,9)                                  |
+| special-codes          | String   | 特殊字符码表(以英文逗号分隔,默认值:~,!,@,#,$,%,^,&,*,:,&lt;,&gt;,&#166;)|
 
 ## 操作步骤
 1. 在脱敏规则中配置脱敏算法;
diff --git a/docs/document/content/user-manual/common-config/builtin-algorithm/mask.en.md b/docs/document/content/user-manual/common-config/builtin-algorithm/mask.en.md
index d442057d267..8dc72f3937d 100644
--- a/docs/document/content/user-manual/common-config/builtin-algorithm/mask.en.md
+++ b/docs/document/content/user-manual/common-config/builtin-algorithm/mask.en.md
@@ -141,12 +141,12 @@ Type: GENERIC_TABLE_RANDOM_REPLACE
 
 Attributes:
 
-| *Name*          | *DataType* | *Description*                         |
-|-----------------|--------|---------------------------------------|
-| uppercase-letter-codes | String   | Uppercase letter (No Split) |
-| lowercase-letter-codes | String   | Lowercase-letter (No Split) |
-| digital-random-codes   | String   | Number (No Split)   |
-| special-codes          | String   | Special code (No Split)|
+| *Name*                 | *DataType* | *Description*                                                                                                    |
+|------------------------|--------|------------------------------------------------------------------------------------------------------------------|
+| uppercase-letter-codes | String   | Uppercase letter codes (separate with comma, default value: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) |
+| lowercase-letter-codes | String   | Lowercase-letter codes (separate with comma, default value: a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) |
+| digital-random-codes   | String   | Numbers (separate with comma, default value: 0,1,2,3,4,5,6,7,8,9)                                                |
+| special-codes          | String   | Special codes (separate with comma, default value: ~,!,@,#,$,%,^,&,*,:,&lt;,&gt;,&#166;)                         |
 
 ## Operating Procedure
 1. Configure maskAlgorithms in a mask rule.
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmUtil.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
similarity index 97%
rename from features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmUtil.java
rename to features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
index 6a00f280d42..97ec9c0b75a 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmUtil.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
@@ -24,10 +24,10 @@ import org.apache.shardingsphere.mask.exception.algorithm.MaskAlgorithmInitializ
 import java.util.Properties;
 
 /**
- * Mask algorithm util.
+ * Mask algorithm props checker.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class MaskAlgorithmUtil {
+public final class MaskAlgorithmPropsChecker {
     
     /**
      * Check single char config.
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
index f1ad57ad859..97f1556ee68 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.Properties;
@@ -53,17 +53,17 @@ public final class KeepFirstNLastMMaskAlgorithm implements MaskAlgorithm<Object,
     }
     
     private Integer createFirstN(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, FIRST_N, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, FIRST_N, getType());
         return Integer.parseInt(props.getProperty(FIRST_N));
     }
     
     private Integer createLastM(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, LAST_M, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, LAST_M, getType());
         return Integer.parseInt(props.getProperty(LAST_M));
     }
     
     private Character createReplaceChar(final Properties props) {
-        MaskAlgorithmUtil.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
         return props.getProperty(REPLACE_CHAR).charAt(0);
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
index 66d1c818388..3d447991886 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.Properties;
@@ -53,17 +53,17 @@ public final class KeepFromXToYMaskAlgorithm implements MaskAlgorithm<Object, St
     }
     
     private Integer createFromX(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, FROM_X, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, FROM_X, getType());
         return Integer.parseInt(props.getProperty(FROM_X));
     }
     
     private Integer createToY(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, TO_Y, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, TO_Y, getType());
         return Integer.parseInt(props.getProperty(TO_Y));
     }
     
     private Character createReplaceChar(final Properties props) {
-        MaskAlgorithmUtil.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
         return props.getProperty(REPLACE_CHAR).charAt(0);
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
index af49a26d9e7..92553e4b37d 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.Properties;
@@ -48,12 +48,12 @@ public final class MaskAfterSpecialCharsAlgorithm implements MaskAlgorithm<Objec
     }
     
     private String createSpecialChars(final Properties props) {
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, SPECIAL_CHARS, getType());
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, SPECIAL_CHARS, getType());
         return props.getProperty(SPECIAL_CHARS);
     }
     
     private Character createReplaceChar(final Properties props) {
-        MaskAlgorithmUtil.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
         return props.getProperty(REPLACE_CHAR).charAt(0);
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
index 2a5fd28ef19..8d834d86712 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.Properties;
@@ -48,12 +48,12 @@ public final class MaskBeforeSpecialCharsAlgorithm implements MaskAlgorithm<Obje
     }
     
     private String createSpecialChars(final Properties props) {
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, SPECIAL_CHARS, getType());
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, SPECIAL_CHARS, getType());
         return props.getProperty(SPECIAL_CHARS);
     }
     
     private Character createReplaceChar(final Properties props) {
-        MaskAlgorithmUtil.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
         return props.getProperty(REPLACE_CHAR).charAt(0);
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
index df90ce4d630..9909d6b09de 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.Properties;
@@ -53,17 +53,17 @@ public final class MaskFirstNLastMMaskAlgorithm implements MaskAlgorithm<Object,
     }
     
     private Integer createFirstN(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, FIRST_N, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, FIRST_N, getType());
         return Integer.parseInt(props.getProperty(FIRST_N));
     }
     
     private Integer createLastM(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, LAST_M, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, LAST_M, getType());
         return Integer.parseInt(props.getProperty(LAST_M));
     }
     
     private Character createReplaceChar(final Properties props) {
-        MaskAlgorithmUtil.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
         return props.getProperty(REPLACE_CHAR).charAt(0);
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
index d4e13894aa0..762d9d289a1 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.Properties;
@@ -53,17 +53,17 @@ public final class MaskFromXToYMaskAlgorithm implements MaskAlgorithm<Object, St
     }
     
     private Integer createFromX(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, FROM_X, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, FROM_X, getType());
         return Integer.parseInt(props.getProperty(FROM_X));
     }
     
     private Integer createToY(final Properties props) {
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, TO_Y, getType());
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, TO_Y, getType());
         return Integer.parseInt(props.getProperty(TO_Y));
     }
     
     private Character createReplaceChar(final Properties props) {
-        MaskAlgorithmUtil.checkSingleCharConfig(props, REPLACE_CHAR, getType());
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, REPLACE_CHAR, getType());
         return props.getProperty(REPLACE_CHAR).charAt(0);
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java
index d6af6796ff6..545f9486933 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java
@@ -17,12 +17,15 @@
 
 package org.apache.shardingsphere.mask.algorithm.replace;
 
+import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import lombok.Getter;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
+import java.util.List;
 import java.util.Properties;
 import java.util.Random;
+import java.util.stream.Collectors;
 
 /**
  * Generic table random replace algorithm.
@@ -33,17 +36,25 @@ public final class GenericTableRandomReplaceAlgorithm implements MaskAlgorithm<O
     
     private static final String LOWERCASE_LETTER_CODES = "lowercase-letter-codes";
     
-    private static final String DIGITAL_RANDOM_CODES = "digital-random-codes";
+    private static final String DIGITAL_CODES = "digital-codes";
     
     private static final String SPECIAL_CODES = "special-codes";
     
-    private String uppercaseLetterCodes = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    private static final String DEFAULT_UPPERCASE_LETTER_CODES = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
     
-    private String lowercaseLetterCodes = "abcdefghijklmnopqrstuvwxyz";
+    private static final String DEFAULT_LOWERCASE_LETTER_CODES = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
     
-    private String digitalRandomCodes = "0123456789";
+    private static final String DEFAULT_DIGITAL_CODES = "0,1,2,3,4,5,6,7,8,9";
     
-    private String specialCodes = "~!@#$%^&*:<>|";
+    private static final String DEFAULT_SPECIAL_CODES = "~,!,@,#,$,%,^,&,*,:,<,>,|";
+    
+    private List<Character> uppercaseLetterCodes;
+    
+    private List<Character> lowercaseLetterCodes;
+    
+    private List<Character> digitalCodes;
+    
+    private List<Character> specialCodes;
     
     @Getter
     private Properties props;
@@ -51,29 +62,14 @@ public final class GenericTableRandomReplaceAlgorithm implements MaskAlgorithm<O
     @Override
     public void init(final Properties props) {
         this.props = props;
-        
-        if (isLeastOneCharConfig(props, UPPERCASE_LETTER_CODES)) {
-            this.uppercaseLetterCodes = props.getProperty(UPPERCASE_LETTER_CODES);
-        }
-        if (isLeastOneCharConfig(props, LOWERCASE_LETTER_CODES)) {
-            this.lowercaseLetterCodes = props.getProperty(LOWERCASE_LETTER_CODES);
-        }
-        if (isLeastOneCharConfig(props, DIGITAL_RANDOM_CODES)) {
-            this.digitalRandomCodes = props.getProperty(DIGITAL_RANDOM_CODES);
-        }
-        if (isLeastOneCharConfig(props, SPECIAL_CODES)) {
-            this.specialCodes = props.getProperty(SPECIAL_CODES);
-        }
+        uppercaseLetterCodes = splitPropsToList(props.getProperty(UPPERCASE_LETTER_CODES, DEFAULT_UPPERCASE_LETTER_CODES));
+        lowercaseLetterCodes = splitPropsToList(props.getProperty(LOWERCASE_LETTER_CODES, DEFAULT_LOWERCASE_LETTER_CODES));
+        digitalCodes = splitPropsToList(props.getProperty(DIGITAL_CODES, DEFAULT_DIGITAL_CODES));
+        specialCodes = splitPropsToList(props.getProperty(SPECIAL_CODES, DEFAULT_SPECIAL_CODES));
     }
     
-    private boolean isLeastOneCharConfig(final Properties props, final String atLeastOneCharConfigKey) {
-        if (!props.containsKey(atLeastOneCharConfigKey)) {
-            return false;
-        }
-        if (0 == props.getProperty(atLeastOneCharConfigKey).length()) {
-            return false;
-        }
-        return true;
+    private List<Character> splitPropsToList(final String props) {
+        return Splitter.on(",").trimResults().splitToList(props).stream().map(each -> each.charAt(0)).collect(Collectors.toList());
     }
     
     @Override
@@ -87,13 +83,13 @@ public final class GenericTableRandomReplaceAlgorithm implements MaskAlgorithm<O
         for (int i = 0; i < chars.length; i++) {
             char c = chars[i];
             if ('A' <= c && c <= 'Z') {
-                chars[i] = uppercaseLetterCodes.charAt(random.nextInt(uppercaseLetterCodes.length()));
+                chars[i] = uppercaseLetterCodes.get(random.nextInt(uppercaseLetterCodes.size()));
             } else if ('a' <= c && c <= 'z') {
-                chars[i] = lowercaseLetterCodes.charAt(random.nextInt(lowercaseLetterCodes.length()));
+                chars[i] = lowercaseLetterCodes.get(random.nextInt(lowercaseLetterCodes.size()));
             } else if ('0' <= c && c <= '9') {
-                chars[i] = digitalRandomCodes.charAt(random.nextInt(digitalRandomCodes.length()));
+                chars[i] = digitalCodes.get(random.nextInt(digitalCodes.size()));
             } else {
-                chars[i] = specialCodes.charAt(random.nextInt(specialCodes.length()));
+                chars[i] = specialCodes.get(random.nextInt(specialCodes.size()));
             }
         }
         return new String(chars);
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/LandlineNumberRandomAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/LandlineNumberRandomAlgorithm.java
index 06e38bbab12..224c6e1bdfa 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/LandlineNumberRandomAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/LandlineNumberRandomAlgorithm.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mask.algorithm.replace;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.List;
@@ -46,7 +46,7 @@ public final class LandlineNumberRandomAlgorithm implements MaskAlgorithm<Object
     }
     
     private List<String> createLandLineNumbers(final Properties props) {
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, LANDLINE_NUMBERS, getType());
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, LANDLINE_NUMBERS, getType());
         return Splitter.on(",").trimResults().splitToList(props.getProperty(LANDLINE_NUMBERS));
     }
     
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/MilitaryIdentityNumberRandomReplaceAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/MilitaryIdentityNumberRandomReplaceAlgorithm.java
index 08a62d9974d..83e3d677f44 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/MilitaryIdentityNumberRandomReplaceAlgorithm.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/MilitaryIdentityNumberRandomReplaceAlgorithm.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mask.algorithm.replace;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import lombok.Getter;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmUtil;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
 
 import java.util.List;
@@ -47,7 +47,7 @@ public final class MilitaryIdentityNumberRandomReplaceAlgorithm implements MaskA
     }
     
     private List<Character> createTypeCodes(final Properties props) {
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, TYPE_CODE, getType());
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, TYPE_CODE, getType());
         return Splitter.on(",").trimResults().splitToList(props.getProperty(TYPE_CODE)).stream().map(each -> each.charAt(0)).collect(Collectors.toList());
     }
     
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmUtilTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
similarity index 74%
rename from features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmUtilTest.java
rename to features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
index 0b90e182862..9a119afd431 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmUtilTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
@@ -24,89 +24,89 @@ import org.junit.Test;
 
 import java.util.Properties;
 
-public final class MaskAlgorithmUtilTest {
+public final class MaskAlgorithmPropsCheckerTest {
     
     @Test
     public void assertCheckSingleCharConfigWithLengthOne() {
         Properties props = PropertiesBuilder.build(new Property("singleChar", "1"));
-        MaskAlgorithmUtil.checkSingleCharConfig(props, "singleChar", "maskType");
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, "singleChar", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckSingleCharConfigWithEmptyString() {
         Properties props = PropertiesBuilder.build(new Property("singleChar", ""));
-        MaskAlgorithmUtil.checkSingleCharConfig(props, "singleChar1", "maskType");
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, "singleChar1", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckSingleCharConfigWithDifferentKey() {
         Properties props = PropertiesBuilder.build(new Property("singleChar", "1"));
-        MaskAlgorithmUtil.checkSingleCharConfig(props, "singleChar1", "maskType");
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, "singleChar1", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckSingleCharConfigWithLengthMoreThanOne() {
         Properties props = PropertiesBuilder.build(new Property("singleChar", "123"));
-        MaskAlgorithmUtil.checkSingleCharConfig(props, "singleChar", "maskType");
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, "singleChar", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckSingleCharConfigWithNull() {
         Properties props = PropertiesBuilder.build();
-        MaskAlgorithmUtil.checkSingleCharConfig(props, "singleChar", "maskType");
+        MaskAlgorithmPropsChecker.checkSingleCharConfig(props, "singleChar", "maskType");
     }
     
     @Test
     public void assertCheckAtLeastOneCharConfigWithLengthOne() {
         Properties props = PropertiesBuilder.build(new Property("AtLeastOneChar", "1"));
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
     }
     
     @Test
     public void assertCheckAtLeastOneCharConfigWithLengthMoreThanOne() {
         Properties props = PropertiesBuilder.build(new Property("AtLeastOneChar", "1234"));
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckAtLeastOneCharConfigWithEmptyString() {
         Properties props = PropertiesBuilder.build(new Property("AtLeastOneChar", ""));
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckAtLeastOneCharConfigWithNull() {
         Properties props = PropertiesBuilder.build();
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckAtLeastOneCharConfigWithDifferentKey() {
         Properties props = PropertiesBuilder.build(new Property("singleChar", "123"));
-        MaskAlgorithmUtil.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
+        MaskAlgorithmPropsChecker.checkAtLeastOneCharConfig(props, "AtLeastOneChar", "maskType");
     }
     
     @Test
     public void assertCheckIntegerTypeConfigWithInteger() {
         Properties props = PropertiesBuilder.build(new Property("integerTypeConfigKey", "123"));
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, "integerTypeConfigKey", "maskType");
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, "integerTypeConfigKey", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckIntegerTypeConfigWithDifferentKey() {
         Properties props = PropertiesBuilder.build(new Property("integerTypeConfigKey", "123"));
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, "integerTypeConfigKey1", "maskType");
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, "integerTypeConfigKey1", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckIntegerTypeConfigWithNotInteger() {
         Properties props = PropertiesBuilder.build(new Property("integerTypeConfigKey", "123abc"));
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, "integerTypeConfigKey", "maskType");
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, "integerTypeConfigKey", "maskType");
     }
     
     @Test(expected = MaskAlgorithmInitializationException.class)
     public void assertCheckIntegerTypeConfigWithNull() {
         Properties props = PropertiesBuilder.build();
-        MaskAlgorithmUtil.checkIntegerTypeConfig(props, "integerTypeConfigKey", "maskType");
+        MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, "integerTypeConfigKey", "maskType");
     }
 }
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java
index d6d119dee74..7be8c6c2abc 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java
@@ -42,7 +42,7 @@ public final class GenericTableRandomReplaceAlgorithmTest {
     
     @Test
     public void assertMask() {
-        maskAlgorithm.init(PropertiesBuilder.build(new Property("uppercase-letter-codes", "ABCD"), new Property("lowercase-letter-codes", "abcd"), new Property("digital-random-codes", "1234"),
+        maskAlgorithm.init(PropertiesBuilder.build(new Property("uppercase-letter-codes", "A,B,C,D"), new Property("lowercase-letter-codes", "a,b,c,d"), new Property("digital-codes", "1,2,3,4"),
                 new Property("special-codes", "~!@#")));
         assertThat(maskAlgorithm.mask(""), is(""));
         assertThat(maskAlgorithm.mask("Ab1!").charAt(0), anyOf(is('A'), is('B'), is('C'), is('D')));