# chunkCountForPlaintext

> **chunkCountForPlaintext**(`plaintextLength`, `chunkSize`): `number`

Defined in: [packages/filecoin-encryption-envelope/src/chunk-layout.ts:84](https://github.com/FilOzone/synapse-sdk/blob/4fe24ea1c76c9b1fa1489b7cdbb1cc279bd2576a/packages/filecoin-encryption-envelope/src/chunk-layout.ts#L84)

Chunk count an *encoder* writes into the `chunk_count` header for a
plaintext of the given length. This is deliberately not the inverse of
[chunkLayout](/reference/filoz/filecoin-encryption-envelope/functions/chunklayout/): a plaintext that is an exact multiple of the chunk
size can be sealed validly as either `k` chunks (last one full) or `k+1`
(last one empty, carrying only its tag), and both decrypt to identical
bytes. We always WRITE the `k` form here, but a decoder must ACCEPT both —
so the header this function produces is checked against
`chunkLayout(ciphertextSize, chunkSize).chunkCount`, never against
`chunkCountForPlaintext` run in reverse on the plaintext size.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `plaintextLength` | `number` |
| `chunkSize` | `number` |

## Returns

`number`