MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / randomBase32

Function randomBase32

apps/kimi-web/src/api/daemon/http.ts:48–58  ·  view source on GitHub ↗
(length: number)

Source from the content-addressed store, hash-verified

46}
47
48function randomBase32(length: number): string {
49 const bytes = new Uint8Array(length);
50 if (globalThis.crypto?.getRandomValues) {
51 globalThis.crypto.getRandomValues(bytes);
52 } else {
53 for (let i = 0; i < bytes.length; i++) {
54 bytes[i] = Math.floor(Math.random() * 256);
55 }
56 }
57 return Array.from(bytes, (byte) => ULID_ALPHABET[byte % 32]).join('');
58}
59
60function createRequestId(): string {
61 return `${encodeBase32(Date.now(), 10)}${randomBase32(16)}`;

Callers 1

createRequestIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected