From 4919f028c884a041da7ff098abb02389b4eac598 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Tue, 18 Apr 2023 03:02:17 +0800 Subject: ✨add envshare docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- envshare/pkg/id.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 envshare/pkg/id.ts (limited to 'envshare/pkg/id.ts') diff --git a/envshare/pkg/id.ts b/envshare/pkg/id.ts new file mode 100644 index 0000000..efdfb5e --- /dev/null +++ b/envshare/pkg/id.ts @@ -0,0 +1,8 @@ +import { toBase58 } from "../util/base58"; +import { ID_LENGTH } from "./constants"; + +export function generateId(): string { + const bytes = new Uint8Array(ID_LENGTH); + crypto.getRandomValues(bytes); + return toBase58(bytes); +} -- cgit v1.2.3-70-g09d2