Code adjustment

For a payment system that allows bank / bank transfers, I need to reliably link the payments to the corresponding user account for which they are intended. To do this, the user must indicate the reference number in the transfer associated with his account.

I would like to generate this number with built-in redundancy (extra characters) so that I can detect and correct up to N of the following (possibly common) errors:

  • Invalid character in sequence (typo)
  • An exchange of two characters (which I assume is the same as two incorrect characters)
  • Missing character in sequence
  • Additional character in sequence

I searched around and it seems that Reed Solomon or BCH are commonly used for this. The only thing I could not find was support for the latter case, that is, additional characters.

Also, I would like the code to have a crash mode, where it says: โ€œThis is so messed up, I can't fix itโ€, instead of giving me a random โ€œfixedโ€ result. I guess I could do it simply by creating sparse reference numbers and hoping that it is unlikely that it accidentally gets into a valid one, but I would prefer something like: "I can fix up to 5 errors, but if it's more than 3, I give up. "

Any thoughts? Thanks!

+4
source share
1 answer

I have not spent so much time studying this yet, but I think I have come up with a preliminary way to solve this problem, which I will continue about:

I will create a 32-character alphabet account reference number. I divided this alphabet into 2 sets of 16 characters, optimizing the sets to minimize the likelihood that a random typo would give a letter from another set. For example, just divide the keyboard in half using the letters in the box with the corners [1], [4], [v], [z] for one set, and the other letters as others.

Then I will use the Reed-Solomon code [14, 8, 7] 16 to encode the 32-bit account number, which I first divided into eight 4-bit characters.

The received message, I go to the reference number, choosing the characters 1, 3, 5, ... from the 1st half alphabet, and the rest from the 2nd half alphabet. That way, I can โ€œre-syncโ€ the reference number if I detect any changed, redundant, or missing characters.

After resynchronizing, the RS code should then allow me to correct up to 3 other typos, and if someone makes more mistakes, they deserve to run into problems with paying them ... :)

I would love to hear any comments that anyone might like about this approach.

+1
source

Source: https://habr.com/ru/post/1443697/


All Articles