Skip to content

号码脱敏处理

bailuyang edited this page Apr 15, 2021 · 4 revisions

号码脱敏处理

号码编码处理流程。联系我们NOC提供一个salt盐值作为编码盐值。使用下面程序代码对号码进行编码后发送到客户端或者在客户端使用编码后的号码拨打。真实号码会被编码成另外一个号码来发起呼叫。这样可以防止号码外泄。

编码代码参考

java

public static String aaas(Long phone,Long salt) { String phoneStr = phone+""; int len=phoneStr.length(); String prefix=""; int suffix=0; if(len>8){ prefix=phoneStr.substring(0,len-8); phoneStr=phoneStr.substring(len-8); phone = Long.valueOf(phoneStr); suffix=8-phone.toString().length(); }else{ phone = Long.valueOf(phoneStr); suffix=len-phone.toString().length(); } Long newphone = (phone & 0xff000000); newphone = (phone & 0xff000000); newphone += (phone & 0x0000ff00) << 8; newphone += (phone & 0x00ff0000) >> 8; newphone += (phone & 0x0000000f) << 4; newphone += (phone & 0x000000f0) >> 4; newphone ^= salt; return prefix+""+newphone+""+suffix+""+newphone.toString().length(); }

JS

function encode_phone(phone,salt){ len=phone.toString().length; prefix=""; suffix=0; if(len>8){ prefix=phone.toString().substr(0,len-8); phone=phone.toString().substr(len-8); suffix=8-parseInt(phone).toString().length; phone=parseInt(phone); }else{ phone=parseInt(phone); suffix=len-phone.toString().length; } newphone = (phone & 0xff000000); newphone += (phone & 0x0000ff00) << 8; newphone += (phone & 0x00ff0000) >> 8; newphone += (phone & 0x0000000f) << 4; newphone += (phone & 0x000000f0) >> 4; newphone ^= salt; return prefix+""+newphone+""+suffix+""+newphone.toString().length; }

PHP

function encode_phone($phone,$salt) { $len=strlen($phone); $prefix=""; $suffix=0; if($len>8){ $prefix=substr($phone,0,$len-8); $phone=substr($phone,$len-8); $phone=(int)$phone; $suffix=8-strlen($phone); }else{ $phone=(int)$phone; $suffix=$len-strlen($phone); } $newphone = ($phone & 0xff000000); $newphone += ($phone & 0x0000ff00) << 8; $newphone += ($phone & 0x00ff0000) >> 8; $newphone += ($phone & 0x0000000f) << 4; $newphone += ($phone & 0x000000f0) >> 4; $newphone ^= $salt; return $prefix.$newphone.$suffix.strlen($newphone); }

简介

短信

语音

云呼叫中心(NXLink)

云呼叫中心(AI自动外呼)

Flash Call

短链

邮件验证码

DID号码

通用

号码检测

WhatsApp

Viber

Zalo ZNS

Super Message API

隐私号(旧)

PNS

坐席(旧版)

AI Agent

Clone this wiki locally