# `mix strongbox.gen.key`
[🔗](https://github.com/hattoriai/strongbox/blob/v0.1.0-dev/lib/mix/tasks/strongbox.gen.key.ex#L1)

Prints a new random key in Base64, for a vault's `keys/0` or
`index_keys/0`.

    $ mix strongbox.gen.key
    $ mix strongbox.gen.key --bytes 16

32 bytes by default: what AES-256-GCM and ChaCha20-Poly1305 take, and
enough for an index key under SHA-256. Use 64 for an index key under
SHA-512, 16 for AES-128-GCM.

Keep it in an environment variable, never in the code or the
repository, and decode it in `config/runtime.exs`:

    config :my_app, :strongbox_key_k1, Strongbox.Key.decode!(System.fetch_env!("STRONGBOX_KEY_K1"))

---

*Consult [api-reference.md](api-reference.md) for complete listing*
