package com.yidian.bcommon.utils


/**
 * author: yinjiacheng
 * date: 6/6/21 2:23 PM
 * description: 敏感信息脱敏操作
 */
object SensitiveInfoUtil {

  /**
   * 身份证号码出生日期脱敏
   */
  fun idCardNumEncrypt(content: String): String {
    if (content.isBlank()) return content
    return content.replace(("(\\d{6})\\d{8}(\\d{4})").toRegex(), "$1********$2")
  }

  /**
   * 手机号前三后四脱敏
   */
  fun mobileEncrypt(mobile: String): String {
    if (mobile.isBlank() || mobile.length != 11) {
      return mobile
    }
    return mobile.replace(("(\\d{3})\\d{4}(\\d{4})").toRegex(), "$1****$2")
  }

}
