checkdigit.crc.validate

checkdigit.crc.validate(data: str, polynomial: str) bool[source]

Validates whether the check digit matches a block of data.

Parameters:
  • data – A string containing binary digits including the check digit

  • polynomial – Polynomial to use

Returns:

A boolean representing whether the data is valid or not

Return type:

bool

Examples

>>> from checkdigit import crc
>>> crc.validate("1010101", "101")
True
>>> crc.validate("1000101", "101")
False