aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/pkg/id.ts
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/id.ts')
-rw-r--r--pkg/id.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/id.ts b/pkg/id.ts
new file mode 100644
index 0000000..efdfb5e
--- /dev/null
+++ b/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);
+}