diff options
| author | 2023-04-17 18:53:55 +0000 | |
|---|---|---|
| committer | 2023-04-17 18:53:55 +0000 | |
| commit | b135aac8531c1e1488147ad8c6f98eddbdbe0c99 (patch) | |
| tree | 189e9fea7109564d63207e231d5b0e5624243072 /pkg/id.ts | |
| download | HydroRoll-b135aac8531c1e1488147ad8c6f98eddbdbe0c99.tar.gz HydroRoll-b135aac8531c1e1488147ad8c6f98eddbdbe0c99.zip | |
Initial commit
Created from https://vercel.com/new
Diffstat (limited to 'pkg/id.ts')
| -rw-r--r-- | pkg/id.ts | 8 |
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); +} |
