js 生成随机字符串 + 时间戳

function randomString(len) {
  len = len || 32;
   let timestamp = new Date().getTime();
    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';    
  let maxPos = $chars.length;
  let randomStr = '';
  for (let i = 0; i < len; i++) {
      randomStr += $chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return randomStr + timestamp;
}

你可能感兴趣的:(js 生成随机字符串 + 时间戳)