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

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# [access]: access keys and encryption

> The encrypt, key_env, get_key_url and send_key settings, key format and limits, how keys are stored and sent, and how the files are encrypted.

`[access]` makes the installer ask for a key and encrypts the packaged files with it. The key is never written into `bach.toml`. Walkthrough and limits: [Access keys](/docs/guides/paid-apps.md).

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[access]
get_key_url = "https://example.com/buy"
```

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach key --out keys.txt
bach build --key-file keys.txt
```

| Setting | Default | Meaning |
| - | - | - |
| `encrypt` | `true` | Encrypt the packaged files |
| `key_env` | `"BACH_ACCESS_KEY"` | Environment variable the build reads the key from, when `--key-file` isn't given |
| `get_key_url` | none | `https` page for **Get a key** |
| `send_key` | `true` with `[updates]`, else `false` | Send `Authorization: Bearer <key>` to the host of `updates.feed`. Needs `[updates]`. |

With `encrypt = false`, `send_key` must be on, otherwise the section does nothing and Bach refuses it.

## Keys

* 8 to 128 characters: letters, digits and `- _ . ~ + / = :`. `bach key` makes random ones.
* A key file holds one key per line; blank lines and lines starting with `#` are skipped. Up to 1000 keys, each opening the setup file on its own. The environment variable holds one key.
* Silent installs take `--key-file` or `BACH_ACCESS_KEY`. No key: exit code 2. Wrong key: 1.

## On the user's computer

With `[updates]`, the key is stored under `HKCU\Software\Bach\Access`, protected with the Windows Data Protection API for that user, and deleted on uninstall. Programs running as that user can still ask Windows to read it, as with saved browser passwords. It is sent only to the feed's host; redirects to other hosts are followed without it.

## How files are protected

The files are encrypted with a random key. For each access key, that random key is stored once, locked with a key derived from the access key using Argon2id (64 MiB, 3 passes) and ChaCha20-Poly1305. The archive is encrypted in authenticated 64 KB pieces, so a changed or shortened file fails with a message. A setup file that asks for more than 256 MiB of memory, or an unknown method, is refused.

Trying a key takes about a third of a second. With 17 keys or more, each stored copy also has a one-byte tag that lets setup find the right one quickly; random keys make this safe.

File names and sizes remain visible without a key, and installed files are ordinary files. Setup files made with one key for the whole file, from older versions, still open.

Not allowed with: `download` components while encrypting, `kind = "zip"` profiles, and `--msi`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.