Home / Function/ generateRandomString() — supabase Function Reference

generateRandomString() — supabase Function Reference

Architecture documentation for the generateRandomString() function in JwtGeneratorSimple.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  75de995c_0476_2c0a_9a5e_2fe2411c0ad5["generateRandomString()"]
  3431b1af_4217_9400_15cc_2f2734269fce["generateKeys()"]
  3431b1af_4217_9400_15cc_2f2734269fce -->|calls| 75de995c_0476_2c0a_9a5e_2fe2411c0ad5
  style 75de995c_0476_2c0a_9a5e_2fe2411c0ad5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/components/JwtGenerator/JwtGeneratorSimple.tsx lines 7–25

const generateRandomString = (length: number) => {
  const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  let result = ''

  const MAX = Math.floor(256 / CHARS.length) * CHARS.length - 1
  const randomUInt8Array = new Uint8Array(1)

  for (let i = 0; i < length; i++) {
    let randomNumber: number
    do {
      crypto.getRandomValues(randomUInt8Array)
      randomNumber = randomUInt8Array[0]
    } while (randomNumber > MAX)

    result += CHARS[randomNumber % CHARS.length]
  }

  return result
}

Subdomains

Called By

Frequently Asked Questions

What does generateRandomString() do?
generateRandomString() is a function in the supabase codebase.
What calls generateRandomString()?
generateRandomString() is called by 1 function(s): generateKeys.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free