Struggling with polynomial Long Division in $GF(256)$ I'm currently trying to build a QR Code generator, which has lead me to studying a bit of abstract algebra - more specifically, finite fields.
I've studied quite a bit on my own and I'm at the point where I'm trying to implement an algorithm for polynomial long division in the $GF(256)$, but my results don't match with the neither the QR Code specification examples nor with this tutorial that I have been following as well. So I thought I could perform a quick polynomial division here to see if I can figure out if I actually understand the whole process as a whole.
I'm going to divide $p(x) = 5x^4 + 32x^3 + 27x^2 + 7x + 3$ by $q(x) = x^2 + 5x + 1$.
I start out by multiplying $q(x)$ by $5x^2$, which gives me $5x^4 + 17x^3 + 5x^2$ (here I use the fact that each element can be represented as a power of the primitive. So $5 \cdot 5 = (\alpha^{50})^2 = 17$). Then, I add this result with $p(x)$, which gives me $49x^3 + 30x^2 + 7x + 3$ (also, here I use the fact that every element in this field can be represented as a polynomial with coefficients being $0$ or $1$. This means that an addition is equivalent to a XOR operation of bit the respective bit strings).
I then repeat this same process two more times:

*

*Multiply $q(x)$ by 49x, resulting in $49x^3 + 245x^2 + 49x$, to then add it to the remainder of the previous operation, giving me $235x^2 + 54x + 3$.

*Multiply $q(x)$ by 235, resulting in $235x^2 + 48x + 235$, to then add it to the remainder of the previous operation, giving me $6x + 232$, which is the final remainder.

Therefore, the quotient is $5x^2 + 49x + 235$ and the remainder is $6x + 232$.
Am I doing something wrong? If so, then what? I'd appreciate any kind of feedback.
Thanks in advance.
 A: I made a crash course for Pari and used an online version and got
? c=ffgen(c^8+c^4+c^3+c^2+Mod(1,2))
% = c

? divrem((c^2+1)*x^4+(c^5)*x^3+(c^4+c^3+c+1)*x^2+(c^2+c+1)*x+(c+1),(x^2+(c^2+1)*x+1))
% = [(c^2 + 1)*x^2 + (c^5 + c^4 + 1)*x + (c^7 + c^6 + c^5 + c^3 + c + 1), 
     (c^6 + c^4 + c^2 + c)*x + (c^7 + c^6 + c^5 + c^3)]~

The symbols ? and % are the input and the output prompt.
I hope I did use this Pari calculations correctly.
Now I used Maxima (I used my Windows version) to check if I used the correct polynomials. I substituted $c$ by $2.$
(%i) (c^2+1)*x^4+(c^5)*x^3+(c^4+c^3+c+1)*x^2+(c^2+c+1)*x+(c+1), c=2;
(%o) 5*x^4+32*x^3+27*x^2+7*x+3

(%i) x^2+(c^2+1)*x+1, c=2;
(%o) x^2+5*x+1

(%i) (c^2 + 1)*x^2 + (c^5 + c^4 + 1)*x + (c^7 + c^6 + c^5 + c^3 + c + 1), c=2;
(%o) 5*x^2+49*x+235

(%i) (c^6 + c^4 + c^2 + c)*x + (c^7 + c^6 + c^5 + c^3), c=2;
(%o) 86*x+232

In Maxima %i is the input prompt and %o is the output prompt.
There is a Maxima online version here. Simply input
(c^2+1)*x^4+(c^5)*x^3+(c^4+c^3+c+1)*x^2+(c^2+c+1)*x+(c+1),c=2;
(x^2+(c^2+1)*x+1),c=2;
(c^2 + 1)*x^2 + (c^5 + c^4 + 1)*x + (c^7 + c^6 + c^5 + c^3 + c + 1),c=2;
(c^6 + c^4 + c^2 + c)*x + (c^7 + c^6 + c^5 + c^3),c=2;

and press Clic.
So  in $GF(256)$ the quotient is $5x^2+49x+235$ and the remainder is $86x+232.$
These calculations were done very poorly, but I am not familiar with the tools. I only want to show you there are tools to make such calculation that are error prone if you do them by hand.

To calculate this by hand the coefficients should be seen as polynomials.
So $12$ is binary $1100$ is the polynomial $1 \cdot c^3+1\cdot c^2 +0 \cdot c + 0.$
If you ad two numbers you have to add the two polynomials which means for each power you add the coefficients. Because the calculations are modulo 2 you simpli can XOR the digits of the numbers.
To multiply the numbers you have to multiply the polynomials and if there highest exponent is 8 or higher you have to divide  the result by your irreducible polynomial and take the remainder. A more efficient way is to use the Log-/Antilog-tables, e.g.
$$ 235×5=2^{235}×2^{50}=2^{235+50}=2^{285}=2^{30}=96 $$ The exponent must be reduced modulo 255.
A: After reading your source a bit: In your case the numbers are not actually used as numbers, but as polynomial with their coefficients encoded by the binary digits of that number.
So then note that $235\times 5\neq 48$:
$$ 235\times 5= 235 + ((235\times 2)+285)\times 2+285 = 96$$
This gives you then a remainder of $86x+232$.
