TITLE: Does $A^2 \cong B^2$ imply $A \cong B$ for rings?
QUESTION [21 upvotes]: If $A$ and $B$ are two unital rings such that $A \times A \cong B \times B$, as rings, does it follows that $A$ and $B$ are isomorphic (as rings)?

I believe that the answer is no, but I can't come up with a counterexample. A similar question for groups has already been asked - the answer is not straightforward.
Here is a possibly related question, but there are $R$-modules isomorphisms.
[If $A$ and $B$ are fields, then we can see $B^2$ as a $2$-dimensional $A$-vector space, so that $A \cong B$ as $A$-vector spaces, because they have the same dimension. I may be wrong about this, but anyway this is not sufficient to get a field isomorphism.]
Thank you for your comments!

REPLY [10 votes]: In this answer (and with more detail in this answer) I gave an example, due to Sundaresan, of a compact Hausdorff space $X$ such that if $Y$ and $Z$ are the results of adding one and two isolated points, respectively, to $X$, then $X\sim Z\not\sim Y$, where $\sim$ denotes homeomorphism. Thus, $X\sqcup X\sim X\sqcup Z\sim Y\sqcup Y$, even though $X\not\sim Y$. Let $A=C(X)$ and $B=C(Y)$; then
$$A\times A\cong C(X\sqcup X)\cong C(Y\sqcup Y)\cong B\times B\;,$$
but $A\not\cong B$.