function rs(&$binary, $bytes, $datablock, $rsblock) {
        $blocks = floor(($bytes + 2) / $datablock);
        $rs = new ReedSolomon($rsblock);

        for ($b = 0; $b < $blocks; $b++) {
            $buf = array();
            $p = 0;
            for ($n = $b; $n < $bytes; $n += $blocks)
                array_push($buf, $binary[$n]);

            $enc = $rs->encodeArray($buf);

            // comes back reversed
            $p = $rsblock - 1;
            for ($n = $b; $n < $rsblock * $blocks; $n += $blocks)
                $binary[$bytes + $n] = $enc[$p--];
        }
    }