From 51f83f4145afac080e9f1774d0528109d320ab61 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 5 Jun 2023 15:51:56 +0800 Subject: [PATCH] =?UTF-8?q?uuid=E5=A2=9E=E5=8A=A0=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/crypto.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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) } /**