js实现脱敏

str:字符串 beginStr:开始位置 endStr:结束位置;

common.desensitization = function(str,beginStr,endStr){
	var len = str.length;
	var leftStr = str.substring(0,beginStr);
	var rightStr = str.substring(endStr,len);
	var str = ''
	var i = 0;
	try {
		for (i = 0; i < endStr-beginStr;i++) {
			str = str + '*';
		}
	} catch (error) {
		
	}
	str = leftStr + str + rightStr;
	return str;
}

 

posted @ 2020-12-01 00:27  安静、、、  阅读(925)  评论(0编辑  收藏  举报