Code 39 Mod 43 Checksum

Published on

I needed to do some work with barcodes recently, specifically I needed to handle Code 39 Mod 43 barcodes.

Given a barcode string this function should return the relevant Mod 43 checksum.

public class Code39 {
/// Returns the expected checksum for the specified barcode
public string ValidateMod43(string barcode) {
int subtotal = 0;
const string charSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
for (int i = 0; i < barcode.Length; i++) {
subtotal += charSet.IndexOf(barcode.Substring(i, 1));
}
return charSet.Substring(subtotal%43, 1);
}
}

I adapted this from a VBA script so if there’s a better way of doing it let me know!

I know you don't have endless hours to learn ASP.NET

Cut through the noise, simplify your web apps, ship your features. One high value email every week.

I respect your email privacy. Unsubscribe with one click.