SOURCE

// 输入手机号
const ccc = encode('16607492809')

console.log('加密',ccc)
console.log('解密',decode(ccc))

function encode(phone){
    const a = phone.substring(0,3)
    const b = phone.substring(3,7)
    const c = phone.substring(7)

    const code = `${btoa(~a)}_${btoa(~b)}_${btoa(~c)}`
    return encodeURIComponent(code)
}

function decode(str){
    let phone = ''
    try{
        const pp = decodeURIComponent(str)
        const[a,b,c] = pp.split('_')
        const a1 = atob(a)
        const b1 = atob(b)
        const c1 = atob(c)
        phone = String(~a1) + ~b1 + ~c1
    }catch(e){
        console.error('解密失败',e.message)
    }
    return phone
}
console 命令行工具 X clear

                    
>
console