> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# crypt.generatebytes

> Generates random bytes with random byte generator and returns them Base64-encoded as a Lua string.

<div className="real-function-page">
  ```lua theme={null}
  crypt.generatebytes(size: number): string
  ```

  ## Arguments

  <ParamField path={"size"} type={"number"} required>
    Number converted to an integer before allocation. Values less than or equal to 0 are changed to 1.
  </ParamField>

  ## Returns

  <ResponseField name={"encoded"} type={"string"}>
    Base64 encoding of the generated raw bytes. The returned string length is not the requested byte count.
  </ResponseField>

  ## Example

  Generate bytes and decode the Base64 result when raw bytes are needed.

  ```lua theme={null}
  local encoded = crypt.generatebytes(16)
  local raw = base64_decode(encoded)

  print(encoded)
  print(#encoded)
  print(#raw)
  ```
</div>
