/**
 * 获取随机字符串
 * @param {number} length
 * @returns {String}
 */
export function getNonce(length) {
  typeof length !== 'number' && (length = 16)
  const chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'k', 'm', 'n', 'p', 'r', 's', 't', 'w', 'x', 'y', 'z', 2, 3, 4, 5, 6, 7, 8]
  const charsLen = chars.length;
  let str = ''
  for (let i = 0; i < length; i++) {
    const idx = parseInt(charsLen * Math.random())
    let _char = chars[idx];
    if (typeof _char === 'string' && idx % 2) {
      _char = _char.toUpperCase()
    }
    str += _char
  }
  return str
}
