随机生成32位uid

//随机32位uid
function uuidGenerator() {
    var originStr = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
        originChar = '0123456789abcdef',
        len = originChar.length;
    return originStr.replace(/x/g, function(match) {
        return originChar.charAt(Math.floor(Math.random() * len))
    })
}

uuidGenerator()  //"da741659-5395-0040-6415-c8093dde4b80"

你可能感兴趣的:(常用方法,js,算法)