How exactly does magnetism rip data from things? I once read in a book that if a magnetar were to pass by the earth that it would rip the data from every single credit card on the planet's face. I'm not entirely sure if I'm in the right place for this, but how exactly does that work?
 A: Data in magnetic storage media is stored by patterns of different magnetization directions. Writing occurs by subjecting them to a strong magnetic field that flips the magnetization direction to align with it, while reading happens using weaker fields (or optomagnetic effects).
A very strong magnetic field across Earth would presumably change the orientation of storage media and erase them (even if only some bits flip it can make the data inaccessible).
0.4 T is apparently enough to erase a credit card, while magnetars have $B=10^9$ to $10^{11}$ T fields. However, they decline as $1/r^3$, so the distance where they are just able to erase cards is $r^3 = B/0.4$ or $r\approx 1.4 B^{1/3} \approx 1400$ to $6300$ times the surface radius where $B$ is measured. Since this is about 10 km, the credit-card erasing range is somewhere around 14,000 and 63,000 km: it would have to pass very close to Earth to do this, literally a few Earth radii away. Since magnetars weigh about a solar mass credit cards and hard drives would be the least of our problems in this scenario.
