# `SefazDanfe.Barcode`
[🔗](https://github.com/devaction-labs/sefaz_danfe/blob/v0.1.0/lib/sefaz_danfe/barcode.ex#L1)

Code 128 subset C (ISO/IEC 15417), the barcode the DANFE prints for the access key.

Subset C encodes two digits per symbol, so the 44 digits of an access key are 22 symbols between
a start symbol and a check symbol, followed by the stop pattern: 277 modules in all. `encode/1`
gives the bars as `{offset, width}` pairs in modules, which the layout draws as rectangles.

# `bars`

```elixir
@type bars() :: [{non_neg_integer(), pos_integer()}]
```

# `checksum`

```elixir
@spec checksum([0..99]) :: 0..102
```

The check symbol: the start value plus each value times its position, modulo 103.

# `encode`

```elixir
@spec encode(String.t()) :: {:ok, bars()} | {:error, :invalid}
```

The bars of `digits` as `{offset, width}` in modules, from the left edge of the first bar. The
total width is `modules/1`.

# `modules`

```elixir
@spec modules(String.t()) :: pos_integer()
```

The width of the code of `digits` in modules (`11 * (pairs + 2) + 13`).

# `patterns`

```elixir
@spec patterns() :: [String.t()]
```

The widths of every symbol, as the table lists them (value 0 to 106).

# `symbols`

```elixir
@spec symbols(String.t()) :: {:ok, [0..106]} | {:error, :invalid}
```

The symbol values of `digits` in subset C: start, one value per pair of digits, the check symbol
and the stop.

`{:error, :invalid}` unless `digits` is a non-empty string of digits of even length.

---

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