Magnetic Stripe IATA Encoding

This post coves the encoding scheme defined by the IATA, originally for use in the airline industry.  This is the encoding found on airline boarding passes, in fact.

It is commonly found on track 1 of magnetic stripes, and track 3 on some cards.  Unlike the ABA encoding, this is alphanumeric.

Character Encoding Overview

  • Each character is 7 bits in length.  Six bits for the character itself and one odd parity bit.
  • The character set includes 64 symbols, ranging from 0x20 – 0x5f on the ASCII table.
  • Encoded characters are offset from ASCII by 32.  E.g., the number 0 is stored as 16 decimal.  Adding 32 gives us 48, the ASCII character 0.
  • Values are encoded in Least Significant Bit (LSB) order.

The encoding follows most of the ABA encoding scheme, but with a larger character set and different ASCII offset.  Calculating the LRC and parity bits however is identical, and the same code can actually be used to decode both ABA and IATA.

Data Formatting

  • Always starts with a percent sign, the start sentinel.
  • Always ends with a question mark, the end sentinel.
  • The field separator is a caret (^).  This typically separates the account number from the name, and the name from the expiration date.
  • A 7bit Longitudinal Redundancy Check character follows the end sentinel.  Like ABA encoding, it uses an even parity bit.  The 7th bit is a odd parity bit of the first 6 bits, just like a normal encoded character.
  • On track 1, can hold up to 79 characters.  On track 3, it can hold up to 101 characters.

For information on how to calculate the LRC, follow the instructions in the ABA encoding post.

Common Data Formatting

  1. Start Sentinel
  2. Format Code.  A single character to define the layout, usually ‘B’
  3. The Primary Account Number (PAN), up to 19 characters in length.
  4. Field Separator
  5. Name of account holder.  Format is “SURNAME/GIVEN NAME M” (middle initial).  Supports up to 26 characters.  Cards vary on how they truncate, some eliminating the / used to separate surname from given.  Not all cards will have a middle initial.
  6. Field Separator
  7. Expiration date in YYMM
  8. Additional data up the remaining space left on the track.
  9. End Sentinel
  10. LRC

Not all cards follow this format, and some even use a different field separator.