uuid增加连接符
parent
7323499dae
commit
51f83f4145
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "crypto.web.js",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"type": "module",
|
||||
"description": "crypto.js浏览器版本,提供常用的加密封装",
|
||||
"keywords": [
|
||||
|
|
|
@ -5,7 +5,7 @@ const subtle = window.crypto.subtle
|
|||
var __stamp__ = 0
|
||||
var __inc__ = 0 //用于生成保证唯一的uuid种子
|
||||
|
||||
export function uuid() {
|
||||
export function uuid(pipe = '-') {
|
||||
var rand = Math.random().toString(16).slice(2) + Math.random().toString(16).slice(2)
|
||||
var now = (~~(Date.now() / 1000)).toString(16)
|
||||
|
||||
|
@ -15,8 +15,8 @@ export function uuid() {
|
|||
__stamp__ = now
|
||||
__inc__ = 0
|
||||
}
|
||||
rand = __stamp__ + __inc__.toString(16) + rand
|
||||
return rand.slice(0, 24)
|
||||
rand = __inc__.toString(16) + rand
|
||||
return __stamp__ + pipe + rand.slice(0, 4) + pipe + rand.slice(4, 8) + pipe + rand.slice(-8)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue