You can divide both sides by but by inspection
Yes, the division by is legal. However, these sorts of problems are easiest if you realise that for two complex expressions to be equal, their real parts have to be equal and their imaginary parts have to be equal.
So if you write each side in terms of its real and imaginary parts, then you can equate real and imaginary parts.
In your case:
Now equate real and imaginary parts:
and .