(randomBytes: (n: number) => Uint8Array = defaultRandomBytes)
| 77 | // Generate a short random id: 16 random bytes (a UUID's worth of |
| 78 | // entropy) Crockford base32-encoded into 26 lowercase characters. |
| 79 | export function randomId(randomBytes: (n: number) => Uint8Array = defaultRandomBytes): string { |
| 80 | return encodeBase32(randomBytes(16)); |
| 81 | } |
| 82 | |
| 83 | function defaultRandomBytes(n: number): Uint8Array { |
| 84 | const bytes = new Uint8Array(n); |
no test coverage detected