zplCore.comzplCore.com

Checksums

public static class Checksums

Public check digit algorithms used by the barcode symbologies (GS1 mod 10, Luhn, mod 11, Code 39 mod 43, Code 93 mod 47, ISO/IEC 7064, UPU S10, MSI variants …). All methods take the data without the check character.

Methods

Method SignatureReturnsDescription
static # CodabarMod16(string data)charCodabar mod 16 check character over the data including start/stop characters.
static # Code11(string data, bool twoDigits = true)stringCode 11 C (and with twoDigits also K) check digits; '-' counts as 10.
static # Code39Mod43(string data)charCode 39 mod 43 check character.
static # Code93Mod47(string data)stringCode 93 check characters C and K (mod 47, weights 1..20 and 1..15). Data must be in the Code 93 basic set.
static # DeutschePostMod10(string digits)intDeutsche Post Leitcode / Identcode check digit (weights 4 and 9 from the left).
static # DeutschePostMod11(string digits)intDeutsche Post mod 11 (weights 2..7 from the right; results 10 and 11 become 0).
static # IsValidMod10(string digitsWithCheck)boolTrue when the last digit of digitsWithCheck is its GS1 mod 10 check digit.
static # Iso7064Mod11_10(string digits)intISO/IEC 7064 MOD 11-10 (hybrid system, numeric).
static # Iso7064Mod37_2(string data)charISO/IEC 7064 MOD 37-2 (alphanumeric, check character 0-9, A-Z or '*'); used by ISBT 128.
static # Iso7064Mod97_10(string data)intISO/IEC 7064 MOD 97-10 (as in IBAN): returns the two check digits 02..98.
static # Luhn(string digits)intLuhn (mod 10, double every second digit from the right); also the MSI mod 10 check.
static # Mod10(string digits)intGS1 mod 10 (weights 3,1 from the right): EAN/UPC, ITF-14, SSCC, GTIN, GLN.
static # Mod10Weighted(string digits, params int[] weightsFromRight)intWeighted mod 10 with the given weights applied from the right (cycling), result (10 - sum mod 10) mod 10.
static # Mod11(string digits, int maxWeight = 7)intMod 11 with weights 2..maxWeight from the right; returns 0..10 (10 is usually printed as 'X').
static # Msi(string digits, MsiChecksum kind)stringMSI check digits: "Mod10", "Mod11", "Mod1010" (two mod 10) or "Mod1110" (mod 11 then mod 10).
static # Ppn(string data)stringPPN (pharmacy product number) check digits: mod 97 over the character values with weights 2, 3, 4 …
static # UpuS10(string serial8)intUPU S10 check digit over the 8-digit serial number (weights 8,6,4,2,3,5,9,7).
static # Vin(string vin)charVIN check character (position 9) of a 17-character VIN (the check position itself is ignored).