Not sure if this is the best place to ask but I own an engineering company.
We have expanded and I need a way to ensure part numbers are not entered incorrectly.
Part numbers are of the form:
$$Aaaxxx-xxxx-c$$
Ignore the the dash '-' characters, they are just there to make things more readable and are not stored in the database.
'A' is a single character [A..Z] or one of '!', '~', '#' or '$'
'a' is a single character [A..Z],
'x' is a digit [0..9]
I have yet to define 'c' this is intended to be a check character to ensure no bad entries.
Typical typing errors are:
Swapping two characters
Entering the wrong one
I am looking for suggestions on where I can look to find an algorithm to define 'c'.
I am not worried about trying to correct an error only to recognise it.
In Python you can use the following code to calculate the last symbol for an arbitrary input string. The function is based on built-in MD5 function. MD5 function is very sensitive to input - the output changes drasticly for minor input changes. The function is slightly adjusted to ignore dashes and spaces in the input string.
MD5 is not the fastest way to compute a hash (on the contrary). But on modern computers it's not at issue. And you will find MD5 implementations in all modern programming languages.