BinaryProvider gives you optional at-rest encryption for your config files. When you supply an encryptionKey, the plugin encrypts every write and decrypts every read using XChaCha20-Poly1305 authenticated encryption — a construction that provides both confidentiality and integrity. Choosing the right key-derivation function (KDF) for your situation is the single most important decision when enabling encryption.
What BinaryProvider encrypts
BinaryProvider stores config data as compact binary. Without an encryptionKey the bytes are unencrypted but still not human-readable JSON or YAML. When you add a key:
- Every file write is sealed with XChaCha20-Poly1305, an authenticated encryption scheme that detects tampering.
- The raw bytes on disk are opaque — no field names, no values, no structure are legible without the key.
- If you need to inspect values during development, use
exportAs()to decode the config into JSON, YAML, or TOML in memory.
Choosing a KDF
The plugin supports two key-derivation strategies. Pick based on where the key comes from — not on preference.| Scenario | KDF | Code |
|---|---|---|
| Random / high-entropy key (env var, OS keyring) | "sha256" (default) | BinaryProvider({ encryptionKey: "key" }) |
| User-entered password | "argon2" | BinaryProvider({ encryptionKey: password, kdf: "argon2" }) |
| No encryption needed | — | BinaryProvider() |
Basic usage
The example below shows a high-entropy key (for example, one retrieved from the OS keyring at startup) used with the default SHA-256 KDF.Password-based encryption
When the key originates from user input, switch tokdf: "argon2". The call signature is otherwise identical.
Combining with keyring fields
File-level encryption andkeyring() schema fields are completely independent features. You can use them together: the file is encrypted at rest, and individual sensitive fields are also stored in the OS platform keychain. This is useful when you want general config privacy plus extra protection for high-value secrets like tokens or master keys.
BinaryProvider encryption and keyring() fields protect data through separate mechanisms. Encrypting the file does not remove the need for keyring fields, and vice versa. Use both when your threat model calls for defence-in-depth.Exporting encrypted configs
Because encrypted binary files are not human-readable, useexportAs() to decode them into a readable format for debugging or inspection. The decryption happens in memory — nothing unencrypted is written back to disk.
KeyringOptions as the second argument:
The
encryptionKey travels over Tauri IPC only for operations that actually read or write the encrypted file: load, create, save, and patch. It is intentionally omitted from the IPC payload for delete and exists, which do not need to decrypt the content. Restricting DevTools in production builds is still recommended to minimise the IPC surface area exposed to potential inspection.