biip.gs1.checksums
Checksum algorithms used by GS1 standards.
- biip.gs1.checksums.numeric_check_digit(value)
Get GS1 check digit for numeric string.
- Parameters:
value (
str
) – The numeric string to calculate the check digit for.- Return type:
int
- Returns:
The check digit.
- Raises:
ValueError – If the value isn’t numeric.
References
GS1 General Specification, section 7.9
Example
>>> from biip.gs1.checksums import numeric_check_digit >>> numeric_check_digit("950110153100") # GTIN-13 0 >>> numeric_check_digit("9501234") # GTIN-8 6
- biip.gs1.checksums.price_check_digit(value)
Get GS1 check digit for a price or weight field.
- Parameters:
value (
str
) – The numeric string to calculate the check digit for.- Return type:
int
- Returns:
The check digit.
- Raises:
ValueError – If the value isn’t numeric.
References
GS1 General Specification, section 7.9.2-7.9.4
Example
>>> from biip.gs1.checksums import price_check_digit >>> price_check_digit("2875") 9 >>> price_check_digit("14685") 6