I have inherited a PHP project that could really, really benefit from a form of Forward Error Correction, as it involves (potentially) the users typing in a base64 encoded string of an infinitely variable length. This string is split into groups of 6 characters at present for human ease of transcription and joined back together before processing, but by virtue of introducing humans into the equation errors can and do still occur.
Short strings, or those copy-and-pasted are generally fine. The outliers of manually-typed lengthy ones are where the real benefit would be seen.
I've settled on Reed Solomon being the most likely candidate for achieving this (but I'm happy to be pointed towards a more appropriate FEC by those with more practical experience).
Does anyone know of an open source RS encoder and decoder I can use within this PHP application? I have found several ENcoders I can probably hack at from QRCode libraries but a decoder seem to be mythical. I do of course have the option of taking several C implementations and re-writing them (I'm a programmer not a math expert, so writing one from scratch is probably beyond me).
The data at present looks like this (representation only, probably not valid base64!):
fD48Sa 483CDf 18ACDx UYh5jS PQXNT
I'd either like to apply RS encoding to each block after it has been split (lengthening each block, I accept that and it would be acceptable from a project point of view), OR apply it before the string is split into blocks of 6. From what I understand of RS however that would be the more complex option as the string is then not a fixed length.
What I was hoping to be able to find after the 'eureka' moment of coming up with the FEC idea was something that would allow me to do this:
// messy encode pseudocode for demonstration purposes
$data = "Once upon a time in a land far far away";
$encoded = base64_encode($data);
$split = chunk_split($encoded, 6, ' ');
foreach($split as $chunk) {
$rsEncoded .= rsEncode($chunk) . " ";
}
and then then a similar rsDecode() when it is input.
Any hints appreciated...