# `AshVault.Changes.Encrypt`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/ash_vault/changes/encrypt.ex#L1)

Encrypts the action argument for one field into its `encrypted_<field>` attribute.

Encryption happens in a `before_action` hook, not at `change/3` time, and reads the
**argument** the transformer created — never an attribute, because there is no plaintext
attribute any more. When the argument is absent the changeset is left alone, so a partial
update never clobbers existing ciphertext.

`source_context` is refreshed from `changeset.context` at hook-run time: the callback
context's copy was snapshotted during `for_create`/`for_update`, before a caller had a
chance to `Ash.Changeset.set_context/2`.

## Atomic path

`atomic/3` returns `{:atomic, changeset, %{encrypted_field => blob}}` — the three-element
form, which lets it hand back a changeset with the plaintext scrubbed from `:arguments`
and `:params`. ash_cloak's atomic path uses the two-element form and skips scrubbing
entirely, leaving plaintext in `changeset.arguments`. The crypto runs in the BEAM either
way and the ciphertext is embedded as a literal, so there is nothing to lose by scrubbing.

---

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