MCPcopy
hub / github.com/simstudioai/sim / generateRandomHex

Function generateRandomHex

packages/utils/src/random.ts:25–31  ·  view source on GitHub ↗
(length = 16)

Source from the content-addressed store, hash-verified

23 * @returns Lowercase hex string of the given length
24 */
25export function generateRandomHex(length = 16): string {
26 const bytes = generateRandomBytes(Math.ceil(length / 2))
27 return Array.from(bytes)
28 .map((b) => b.toString(16).padStart(2, '0'))
29 .join('')
30 .slice(0, length)
31}
32
33/**
34 * Generates a cryptographically secure random alphanumeric string.

Callers 1

createRequestIdFunction · 0.90

Calls 3

generateRandomBytesFunction · 0.85
joinMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected