I have an id number that needs to be read off a sheet of paper with a barcode by a scanner. Most of the time this will work flawlessly but sometimes there are mistakes (like if paper is partly torn).
I want to be able to flag the occurrences where the number does not make sense so that a human can review. This need for a high level of accuracy is because the paper is providing consent to enroll in a program and I to need to limit (if not eliminate) someone from being enrolled without consent. So if I just use the id number(123456789) to create the barcode and then scan interprets as 123456788 then the wrong person is automatically enrolled.
My current idea for a solution is to add additional numbers to the barcode that when read could verify that the id number is the correct one, but I am unsure of a good solution for this. An example of this would be to supply 061524-123456789 as the barcode. Now, when processed I can use a formula that verifies the id by adding the digits in groups of three (1+2+3=6, 4+5+6=15, etc..) and comparing to the first group of numbers. The conversion at the time of barcode creating and barcode reading should render the same results else it will be flagged. Obviously, there are problems with the example because the different id numbers could have the same confirmation.
So, does anyone know of a reliable mathematical formula which will create a smaller verification code that can be used to verify later?
I need the "key" to be a shorter in characters as the total number digits needs to be limited.
A programming solution is acceptable.
Note: I am completely out of my league here so I don't know how to tag this question. Help with that is appreciated.