We bought some Magnetic stripe cards and I'm writing a program that will get talked to by a mag card reader. What I need help with is that I can't, for the life of me, find out what characters are valid on track 1,2, and 3. I have my program working, but I would like to have the program raise red flags if someone tries sending it data that wouldnt be able to come from a mag stripe.

Question W/O background: What characters can be encoded on T1,T2,T3 of a mag stripe card? Sources please!

  • How are you talking to it? An API? Pipe? Serial Port? Is it masquerading as a keyboard? – Ben Jan 16 '14 at 16:04
  • HID device. So essentially a keyboard. – PsychoData Jan 16 '14 at 16:47

These are the valid range for standard encoding of track 2, which is the ABA standard: 0x30 to 0x3f in the ASCII character set

0 1 2 3 4 5 6 7 8 9 : ; < = > ?



With enough control over the reader/writer, you can encode bits in anyway you choose though, could make up any system you like.

  • You also might find this helpful for Tracks 1 and 3. TLDR; Track 1 in the one that can carry alphanumeric characters, 2 and 3 are numbers and symbols only. ditechnology.com/mscri.html – Owen Jan 16 '14 at 16:44
  • I'd wondering if t3 can hold :<> as well. I know that it can do ;? and = because those are the special ones, but I'm not sure about :<>, though that second link declares that they have the same 5 bits per character as T2 just more density per inch. And of course beyond A-Z0-9%^? I cant find anything definitive on T1 except that it is 7 bits per character. – PsychoData Jan 16 '14 at 17:03
  • @PsychoData Track 3 can hold :<> – cutrightjm Jan 17 '14 at 4:45
  • @ekaj I assumed it was the same as two, since it was the same start and end delimeters, but do you have anything that documents this? – PsychoData Jan 17 '14 at 13:08
  • @PsychoData I tested it myself – cutrightjm Jan 17 '14 at 13:34

A magstripe holds bits. Tracks one and three are typically recorded at 210 bits per inch (8.27 bits per mm), while track two typically has a recording density of 75 bits per inch (2.95 bits per mm).

Just like a USB stick or any other storage device, you can do whatever you wish with these bits, and use any encoding you desire. You can use full Unicode on a magstrip if need be. IATA and ABA are two popular standards that enforce their own encoding rules for magstrips.

  • 1
    Those bits are interpreted as text and numbers by the interface system. If you can teach my mag stripe reader to give me all 210 bits, then I'll vote your answer up. Otherwise you did not remotely answer my question. I am aware that IATA and ABA are two standards for the FORMAT of the content, not the actual content. I want to know If it is valid to various characters. is a ~ something that I could see if someone swiped their debit card or loyalty card instead or their work ID by accident? do I need to raise flags just because someone grabbed the wrong card? Answer my question and I'll upvote. – PsychoData Jan 16 '14 at 16:44
  • @PsychoData I stand by my answer, bits can be cast as any datatype. Without the OP providing his use, then the general case fits best. – rook Jan 16 '14 at 17:22
  • 1
    you're splitting hairs on the head of some other issue entirely. If I had said that I was trying to encode a configuration onto the stripe in binary, this would be a different story, but your statement isnt even helpful. Not even remotely. – PsychoData Jan 16 '14 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.