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

# crypt.random

Returns a string of `size` random bytes.

```luau theme={null}
crypt.random(size: number): string
```

Each call returns a different result. For random bytes already Base64-encoded use `crypt.generatebytes`; for an AES key use `crypt.generatekey`.

Most commonly used as a raw-randomness source for tokens, salts, and nonces.

## Parameters

| Parameter | Type     | Description                       |
| --------- | -------- | --------------------------------- |
| `size`    | `number` | Number of random bytes to return. |

## Returns

`string` - `size` random bytes.

## Example

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  local random = crypt.random(10)
  =======
  -- crypt.random(size: number): string
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  local token = crypt.random(16)
  print(#token) --> 16
  ```
</CodeGroup>

<Tip>
  Unlike standard math.random, this uses a secure entropy source.
</Tip>
