# Change hash

The sha256 of a change, in the same canonical form in the browser and on the server, so an approval made against a hash can be checked where the change runs. Keys are sorted at every depth, so `{ a, b }` and `{ b, a }` hash the same. Uses Web Crypto: browsers on https or localhost, and Node 20 or later.

- Registry name: `change-hash` (`@candor/change-hash`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/change-hash

## Install

```bash
npx candor-ui add change-hash
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/change-hash`.

## Functions

### changeHash

```ts
changeHash(change: unknown)
```

The sha256 of a change, in the same canonical form in the browser and on the server, so an approval made against a hash can be checked where the change runs. Keys are sorted at every depth, so `{ a, b }` and `{ b, a }` hash the same. Uses Web Crypto: browsers on https or localhost, and Node 20 or later.

### canonicalJson

```ts
canonicalJson(value: unknown)
```

JSON with every object's keys sorted, and `undefined` values left out, as JSON.stringify leaves them out.

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
