check-digit

USPS ACS Keyline Check Digit

I have implemented the "MOD 10" check digit algorithm using SQL, for the US Postal Service Address Change Service Keyline according to the method in their document, but it seems I'm getting the wrong numbers! Our input strings have only numbers in them, making the calculation a little easier. When I compare my results with the results fr...

mod 11 check digit with regex

Is it possible to create a mod 11 check digit routine with a regex statement? THe nubmer is a 10 digit number, Step 1: A = (2nd number * 2) + (3rd number * 4) + (4th number * 8) + (5th number * 5) + (6th number * 10) + (7th number * 9) + (8th number * 7) + (9th number * 3)) Step 2: B = A / 11 (ignor remainder) Step 3: C = B * 11 S...

Generating Luhn Checksums

There are lots of implementations for validating Luhn checksums but very few for generating them. I've come across this one however in my tests it has revealed to be buggy and I don't understand the logic behind the delta variable. I've made this function that supposedly should generated Luhn checksums but for some reason that I haven't...

Correct permutation cycle for Verhoeff algorithm

Hello, I'm implementing the Verhoeff algorithm for a check digit scheme, but there seems to be some disagreement in web sources as to which permutation cycle should form the basis of the permutation table. Wikipedia uses: (36)(01589427) while apparently, Numerical Recipies uses a different cycle and this book uses: (0)(14)(23)(56789),...

Optimizing the Verhoeff Algorithm in R

I have written the following function to calculate a check digit in R. verhoeffCheck <- function(x) { ## calculates check digit based on Verhoeff algorithm ## note that due to the way strsplit works, to call for vector x, use sapply(x,verhoeffCheck) ## check for string since leading zeros with numbers will be lost if (class(x)!="charac...