Re: LRC (longitudinal redundancy check) and Even Parity
| From: | Dominic Schanen | Date: | Thu, 12 Aug 2004 20:33:24 +0000 |
| Subject: | Re: LRC (longitudinal redundancy check) and Even Parity | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193641@lists.php.net to get a copy of this message | ||
I was calculating the LRC before setting even parity. I'm hoping that was my problem. If so, this is the change that I made, in case anyone else can find use in these functions:
/************* LRC ************************/
/*** taken from Perl module String::LRC ***/
function lrc($buffer)
{
$len = 0;
$buffer = setEvenParity($buffer);
if (isset($buffer) && !empty($buffer)){
$len = strlen($buffer);
}
$check = substr($buffer, 0, 1);
for ($i = 1; $i < $len ; $i++) {
$check ^= substr($buffer, $i, 1);
}
return $check;
}
We'll see how this goes tomorrow.
Dominic