# crypto.random.generate

Cryptographically random bytes: --size (default 32B, at most 1KiB) as --encoding hex (default) or base64

# crypto.random.generate

```
crypto.random.generate [--size SIZE] [--encoding hex|base64] → random
```

Cryptographically random bytes: `--size` (default 32B, at most 1KiB) as `--encoding hex` (default) or `base64`. For tokens, OAuth `state`, nonces and salts. Adds `random: { value }` and keeps the rest of the payload.

## Flags

- `--size`: How many random bytes, with a unit: 16B, 32B (default), at most 1KiB.
- `--encoding`: hex (default) or base64.

## Examples

### An OAuth state

```
| crypto.random.generate --size 16B
```

It answers:

```json
{
  "random": {
    "value": "9f2c41d07be35a86c1e0f4a2b9d3e781"
  }
}
```

## Used in

- [Sign in with Google (OAuth login)](/examples/oauth-login-google.md)
