diff --git a/package.json b/package.json index 11c758d..996899d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crypto.web.js", - "version": "1.0.0", + "version": "1.0.1", "type": "module", "description": "crypto.js浏览器版本,提供常用的加密封装", "keywords": [ diff --git a/src/crypto.js b/src/crypto.js index ddce485..b2a2e96 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -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) } /**