> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Function encode_bytes_as_fields

Module: `noir_aztec::utils::conversion::bytes_as_fields`

```rust
pub fn encode_bytes_as_fields<let N: u32>(bytes: [u8; N]) -> [Field; N / 31]
```

Encodes an array of bytes as fields.

Use [`decode_bytes_from_fields`](/aztec-nr-api/v6.0.0/noir_aztec/utils/conversion/bytes_as_fields/fn.decode_bytes_from_fields.md) to recover the original bytes.

The `bytes` array length must be a multiple of 31. If padding is added, it will need to be manually removed after decoding.

## Encoding

Each 31-byte chunk is interpreted as a big-endian integer and stored in a `Field`. For input `[1, 10, 3, ..., 0]` (31 bytes), the resulting `Field` is `1 * 256^30 + 10 * 256^29 + 3 * 256^28 + ... + 0`.
