UNPKG

bsl

Version:

基于React的框架和UI组件

13 lines (11 loc) 375 B
function randomString(len = 32) { /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; const maxPos = $chars.length; let pwd = ''; for (let i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; } export default randomString;