Let $a,b$ be squarefree integers and set $R = \mathbb{Z}[\sqrt{a}]$ and $S = \mathbb{Z}[\sqrt{b}]$. Prove that
1) There is an isomorphism of abelian groups $(R,+) \cong (S,+)$.
Let $\varphi : R \to \mathbb{Z} \times \mathbb{Z}$ be a map of groups such that $\varphi(x+y\sqrt{a}) = (x,y)$. This is a homomorphism since if $x+y\sqrt{a}, w+z\sqrt{a} \in R$, then $$\varphi ((x+y\sqrt{a}) + (w+z\sqrt{a})) = \varphi((x+w) + (y+z)\sqrt{a}) = (x+w,y+z) = (x,y)+(w,z) = \varphi(x+y\sqrt{a}) + \varphi(w+z\sqrt{a}).$$
Now, let $x+y\sqrt{a}\in \ker(\varphi)$. Then $\varphi(x+y\sqrt{a}) = (x,y) = 0$, which is true if and only if $x=0$ and $y=0$, i.e. $x+y\sqrt{a} = 0$, and so the kernel is trivial, and the map is injective.
The map is certainly surjective since $\varphi(x+y\sqrt{a}) = (x,y)$, and $(x,y)$ is a general element of $\mathbb{Z} \times \mathbb{Z}$. Hence $R \cong \mathbb{Z} \times \mathbb{Z}$.
Note that this proof did not depend on the value of $a$, only that it was squarefree. Hence we also have that $S \cong \mathbb{Z} \times \mathbb{Z}$, and so $R \cong S$ as groups under addition.
2) There is an isomorphism of rings $R\cong S$ if and only if $a=b$.
This is the part that I am a bit confused on. The reverse direction is clear, since if $a=b$ they are just the same group so are of course isomorphic. It's the forward direction that I am stuck on.
Hint 1: as abelian groups, $\mathbb{Z}[\sqrt{a}]\cong\mathbb{Z}\oplus\mathbb{Z}$.
Hint 2: what integers have a square root in $\mathbb{Z}[\sqrt{a}]$?