function rsCode($code) { if ($code && strlen($code) == 10) { $data = array(); $rs_code = array(); for ($i = 0; $i < RS_TOTAL_LEN; $i++) { if ($i < RS_DATA_LEN) { $data[] = char_to_num($code[$i]); } else { $data[] = 0; } } $qRrs = new QRrs(); $rs = $qRrs->init_rs(RS_SYMSIZE, RS_GFPOLY, RS_FCR, RS_PRIM, RS_NROOTS, RS_PAD); $newcode =& $data[RS_DATA_LEN]; $qRrsItem = new QRrsItem(); $res = $qRrsItem->encode_rs_char($rs, $data, $newcode); for ($i = 0; $i < RS_DATA_LEN; $i++) { $rs_code[] = num_to_char($data[$i]); } for ($i = 0; $i < count($res); $i++) { $rs_code[] = num_to_char($res[$i]); } $newrs_code = ''; for ($i = 0; $i < count($rs_code); $i++) { $newrs_code .= $rs_code[$i]; } // $newrs_code .= '\0'; return $newrs_code; } return null; }
public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs) { $rs->encode_rs_char($data, $ecc); $this->dataLength = $dl; $this->data = $data; $this->eccLength = $el; $this->ecc = $ecc; }
public static function initRs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) { foreach (self::$items as $rs) { if ($rs->pad != $pad) { continue; } if ($rs->nroots != $nroots) { continue; } if ($rs->mm != $symsize) { continue; } if ($rs->gfpoly != $gfpoly) { continue; } if ($rs->fcr != $fcr) { continue; } if ($rs->prim != $prim) { continue; } return $rs; } $rs = QRrsItem::initRsChar($symsize, $gfpoly, $fcr, $prim, $nroots, $pad); array_unshift(self::$items, $rs); return $rs; }