# CRC.crc

`crc`

, go back to CRC module for more information.
## Specs

crc(:crc_algorithm.params(), iodata()) :: :crc_algorithm.value()

Calculate a CRC checksum for the `input`

based on the crc `params`

given.

`params`

can be an atom for one of the compiled models. See `CRC.list/0`

for
a full list or a Map with parameters to create a model at runtime. The map
given should have all of the following keys:

`width`

- (unsigned integer) representation for the width of the CRC in bits
`poly`

- (unsigned integer) the polynomial used for the CRC calculation
`init`

- (unsigned integer) The initial value used when starting the calculation
`refin`

- (boolean) if the input value should be reflected. This is used for changing between endian's
`refout`

- (boolean) if the outvalue should be reflected when calculation is completed
`xorout`

- (unsigned integer) Final xor value used when completing the CRC calculation

## Examples

```
%{
width: 16,
poly: 0x1021,
init: 0x00,
refin: false,
refout: false,
xorout: 0x00
}
```

You can also extend one of the compiled models at runtime by creating a map
with `extend`

key set to the model you wish to extend and the keys you wish
to override for that model.

For example to override the initial value for the `:crc_16_ccitt_false`

model
to `0x1D0F`

you would pass the following Map as params:

``%{extend: :crc_16_ccitt_false, init: 0x1D0F}``

You can learn more about CRC calculation here: https://www.sunshine2k.de/articles/coding/crc/understanding_crc.html