For a payment system that allows bank/wire transfers, I need to reliably associate payments with the corresponding user account that they are intended for. For this, the user should include a reference number on the transfer that is associated with his account.
I would like to generate this number with built-in redundancy (extra symbols), so that I can detect and correct up to N of the following (probably common) errors:
- An incorrect symbol in the sequence (typo)
- A swap of two symbols (which I guess is the same as two incorrect ones)
- A missing symbol in the sequence
- An extra symbol in the sequence
I searched around a bit and it seems like Reed Solomon or BCH are commonly used codes for this. The only thing I couldn't find is whether they support the last case, i.e. extra symbols.
Also, I would like for the code to have a failure mode where it says: "this is so screwed up, I can't fix it" rather than giving me a random "corrected" result. I guess I could do this simply by generating sparse reference numbers and hoping that it will be unlikely that it will hit a valid one by accident, but I'd rather have something like: "I can correct up to 5 errors, but if it's more than 3, I give up."
Any thoughts? Thank you!