1、手机号,邮箱账号****号加密处理

/**
* @description 手机号加密
* @return 132*****6657
*/
const phoneEncryption = (phoneNum: string) => {
  if (!phoneNum) {
    return '';
  }
  const tel = String(phoneNum);
  const num = tel.substr(0,3) + "*****" + tel.substr(7);
  return num;
}
 
 
/**
* @description 邮箱账号加密
* @return l*****0@163.com
*/
 
const mailEncryption = (email: string) => {
  if (!email) {
    return '';
  }
  let new_email: any = '';
  if (String(email).indexOf('@') > 0) {
    let str = email.split('@'),
      _s = '';
    if (str[0].length > 3) {
      for (var i = 0; i < str[0].length - 3; i++) {
        _s += '*';
      }
    }
    new_email = str[0].substr(0, 1) + _s + str[0].substr(str[0].length - 1) + '@' + str[1]
  }
  return new_email;
}
 
posted @ 2020-09-04 11:36  凹润之之之  阅读(488)  评论(0编辑  收藏  举报