Data on the magnetic stripe is encrypted by polarizing tiny magnetic particles with a special encoder in either south or north pole direction.
The encoded information is accessed by swiping the cards' stripe through a reader. A magnetic card reader, which is a microcontroller-based device, can detect polarity that was stored on the strip and release the door.
How does that work?
It might seem like magic when you swipe them, but those strips on the back of access badges work due to some tiny, magnetized pieces of technology. Track magnetic stripes are linear paths across a magnetic access card in which data is recorded, allowing unique badges to be created for all of the people who use your space. This process works through a process of polarization. A card encoder places information on multiple paths across that magnetic stripe with tiny, embedded magnets that reverse polarity in a pattern unique to that card.
When cardholders swipe their badges, access readers are able to take the number embedded on the track magnetic stripe and check it against their databases. Not every magnetic stripe is made the same — temporary ones, like hotel keys and paper IDs, only need to be slightly magnetized, while access badges and credit cards are magnetized much more strongly.