I would like to know, how to calculate the inverse S-box.
I followed this
link (with affine transformation first, then multiplicative inverse), but the result is wrong. For example, if I use the value 0x52 (01010010 in binary), reverse of this value would be 01001010.
The inverse matrix (for inverse S-Box) is:

Input = 0 1 0 0 1 0 1 0 (LSB First)
Row 0 = 0 0 1 0 0 1 0 1
Bit 0 = 0 0 0 0 0 0 0 0 = 0
Row 1 = 1 0 0 1 0 0 1 0
Bit 1 = 0 0 0 0 0 0 1 0 = 1
Row 2 = 0 1 0 0 1 0 0 1
Bit 2 = 0 1 0 0 1 0 0 0 = 0
Row 3 = 1 0 1 0 0 1 0 0
Bit 3 = 0 0 0 0 0 0 0 0 = 0
Row 4 = 0 1 0 1 0 0 1 0
Bit 4 = 0 1 0 0 0 0 1 0 = 0
Row 5 = 0 0 1 0 1 0 0 1
Bit 5 = 0 0 0 0 1 0 0 0 = 1
Row 6 = 1 0 0 1 0 1 0 0
Bit 6 = 0 0 0 0 0 0 0 0 = 0
Row 7 = 0 1 0 0 1 0 1 0
Bit 7 = 0 1 0 0 1 0 1 0 = 1
The result is 01000101, MSB first that would be 10100010, XOR-ed with final vector 0x52 is 0xf0. The inverse of 0xf0 is 0x5b, which is wrong. It should be 0x48. Where did I make a mistake?