---
title: "crypt.random"
description: "Returns raw secure random bytes."
---

```lua
crypt.random(size: number): string
```

---

## Aliases

None.

---

## Arguments

<ParamField body="size" type="number" required>
  The number of raw random bytes. Numeric input is converted to an integer before the non-negative check.
</ParamField>

---

## Returns

<ResponseField name="bytes" type="string">
  Raw random bytes, without Base64 encoding.
</ResponseField>

Numeric input is converted to an integer before the non-negative check. A negative converted count raises; zero returns an empty string. Fractional input is truncated. Unlike generatebytes there is no explicit 1 MiB cap in this wrapper.

---

## Example

```lua
local bytes = crypt.random(16)
print(#bytes, crypt.base64encode(bytes))
```
