MCPcopy Create free account
hub / github.com/anomalyco/opencode / getRandomBytes

Function getRandomBytes

packages/app/src/utils/id.ts:79–93  ·  view source on GitHub ↗
(length: number)

Source from the content-addressed store, hash-verified

77}
78
79function getRandomBytes(length: number): Uint8Array {
80 const bytes = new Uint8Array(length)
81 const cryptoObj = typeof globalThis !== "undefined" ? globalThis.crypto : undefined
82
83 if (cryptoObj && typeof cryptoObj.getRandomValues === "function") {
84 cryptoObj.getRandomValues(bytes)
85 return bytes
86 }
87
88 for (let i = 0; i < length; i += 1) {
89 bytes[i] = Math.floor(Math.random() * 256)
90 }
91
92 return bytes
93}

Callers 1

randomBase62Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected