[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [local‑first/Protocol](https://evolu.dev/docs/api-reference/common/local-first/Protocol) › encodeAndEncryptDbChange

```ts
function encodeAndEncryptDbChange(
  deps: RandomBytesDep,
): (
  message: CrdtMessage,
  key: Uint8Array<ArrayBufferLike> &
    Brand<"Entropy"> &
    Brand<"Length32"> &
    Brand<"EncryptionKey">,
) => EncryptedDbChange;
```

Defined in: [packages/common/src/local-first/Protocol.ts:1856](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/local-first/Protocol.ts#L1856)

Encodes and encrypts a [DbChange](https://evolu.dev/docs/api-reference/common/local-first/Storage/variables/DbChange) using the provided owner's encryption
key. Returns an encrypted binary representation as [EncryptedDbChange](https://evolu.dev/docs/api-reference/common/local-first/Storage/type-aliases/EncryptedDbChange).

The format includes the protocol version for backward compatibility and the
timestamp for tamper-proof verification that the timestamp matches the change
data.