> ## 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

> 使用 random byte generator 生成随机字节，并以 Base64-encoded Lua string 返回。

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

  ## 参数

  <ParamField path={"size"} type={"number"} required>
    allocation 前传入 integer conversion 的数字。小于或等于 0 的值会改为 1。
  </ParamField>

  ## 返回值

  <ResponseField name={"encoded"} type={"string"}>
    生成的 raw bytes 的 Base64 encoding。返回的 string 长度不是请求的字节数。
  </ResponseField>

  ## 示例

  生成 bytes，并在需要 raw bytes 时解码 Base64 结果。

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

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