使用JavaScript对身份证数据进行加密,具体方法如下:
function formatidcard(idcard) {if(idcard.length == 15){return idcard.replace(/(\d{6})\d{6}(\d{3})/, "$1******$2");} else {return idcard.replace(/(\d{5})\d{6}(\d{6})/, "$1******$2");}}
function formatidcard(idcard) {
if(idcard.length == 15){
return idcard.replace(/(\d{6})\d{6}(\d{3})/, "$1******$2");
} else {
return idcard.replace(/(\d{5})\d{6}(\d{6})/, "$1******$2");
}