void ReedSolomon::encode_data (unsigned char msg[], int nbytes, unsigned char dst[]) { int i, LFSR[npar+1],dbyte, j; for(i=0; i < npar+1; i++) LFSR[i]=0; for (i = 0; i < nbytes; i++) { dbyte = msg[i] ^ LFSR[npar-1]; for (j = npar-1; j > 0; j--) { LFSR[j] = LFSR[j-1] ^ Galois::gmult(genPoly[j], dbyte); } LFSR[0] = Galois::gmult(genPoly[0], dbyte); } for (i = 0; i < npar; i++) pBytes[i] = LFSR[i]; build_codeword(msg, nbytes, dst); }
void encode_data (unsigned char msg[], int nbytes, unsigned char dst[]) { int i, LFSR[NPAR+1],dbyte, j; for(i=0; i < NPAR+1; i++) LFSR[i]=0; for (i = 0; i < nbytes; i++) { dbyte = msg[i] ^ LFSR[NPAR-1]; for (j = NPAR-1; j > 0; j--) { LFSR[j] = LFSR[j-1] ^ gmult(genPoly[j], dbyte); } LFSR[0] = gmult(genPoly[0], dbyte); } for (i = 0; i < NPAR; i++) pBytes[i] = LFSR[i]; build_codeword(msg, nbytes, dst); }