Skip to content

mask(id)

对身份证号进行隐私脱敏处理。

函数签名

typescript
function mask(id: string): string

参数

参数类型说明
idstring身份证号码

返回值

返回脱敏后的身份证号,格式为 前3位 + *********** + 后4位

在线演示

代码示例

typescript
import { mask } from 'china-id-card'

mask('622922197808118498')  // → '622***********8498'
mask('110101900101001')    // → '110***********1001'

基于 GB 11643-1999 标准