Table of Contents

ANSI/ISO BCD Data format

This is a 5-bit Binary Coded Decimal format.
It uses a 16-character set, which uses 4 of the 5 available bits.
The 5th bit is an ODD parity bit, which means there must be an odd number of 1's in the 5-bit character..the parity bit will 'force' the total to be odd.
Also, the Least Significant Bits are read FIRST on the strip.

The sum of the 1's in each case is odd, thanks to the parity bit.
If the read system adds up the 5 bits and gets an EVEN number, it flags the read as ERROR, and you gotta scan the card again. (yeah, I *know* a lot of you out there *already* understand parity, but I gotta cover all the bases…not everyone sleeps with their modem and can recite the entire AT command set at will, you know ;).
See following Figure for details of ANSI/ISO BCD.

ANSI/ISO BCD Data Format

Data Bits   Parity
--------------
b1 b2 b3 b4 b5		Character	Function
0  0  0  0  1		0 (0H)		Data
1  0  0  0  0		1 (1H)		"
0  1  0  0  0		2 (2H)		"
1  1  0  0  1		3 (3H)		"
0  0  1  0  0		4 (4H)		"
1  0  1  0  1		5 (5H)		"
0  1  1  0  1		6 (6H)		"
1  1  1  0  0		7 (7H)		"
0  0  0  1  0		8 (8H)		"
1  0  0  1  1		9 (9H)		"
0  1  0  1  1		: (AH)		Control
1  1  0  1  0		; (BH)		Start Sentinel
0  0  1  1  1		< (CH)		Control
1  0  1  1  0		= (DH)		Field Separator
0  1  1  1  0		> (EH)		Control
1  1  1  1  1		? (FH)		End Sentinel

16 Character 5-bit Set
10 Numeric Data Characters
3 Framing/Field Characters
3 Control Characters

The magstripe begins with a string of Zero bit-cells to permit the self-clocking feature of biphase to “sync” and begin decoding.
A “Start Sentinel” character then tells the reformatting process where to start grouping the decoded bitstream into groups of 5 bits each.
At the end of the data, an “End Sentinel” is encountered, which is followed by an “Longitudinal Redundancy Check (LRC) character.
The LRC is a parity check for the sums of all b1, b2, b3, and b4 data bits of all preceding characters.
The LRC character will catch the remote error that could occur if an individual character had two compensating errors in its bit pattern (which would fool the 5th-bit parity check).

The START SENTINEL, END SENTINEL, and LRC are collectively called “Framing Characters”, and are discarded at the end of the reformatting process.

ANSI/ISO ALPHA Data Format

Alphanumeric data can also be encoded on magstripes.
The second ANSI/ISO data format is ALPHA (alphanumeric) and involves a 7-bit character set with 64 characters.
As before, an odd parity bit is added to the required 6 data bits for each of the 64 characters.

ANSI/ISO ALPHA Data Format

Data Bits         Parity
--------------------
b1 b2 b3 b4 b5 b6 b7		Character	Function
0  0  0  0  0  0  1		space (0H)	Special
1  0  0  0  0  0  0		! (1H)		"
0  1  0  0  0  0  0		" (2H)		"
1  1  0  0  0  0  1		# (3H)		"
0  0  1  0  0  0  0		$ (4H)		"
1  0  1  0  0  0  1		% (5H)		Start Sentinel
0  1  1  0  0  0  1		& (6H)		Special
1  1  1  0  0  0  0		' (7H)		"
0  0  0  1  0  0  0		( (8H)		"
1  0  0  1  0  0  1		) (9H)		"
0  1  0  1  0  0  1		* (AH)		"
1  1  0  1  0  0  0		+ (BH)		"
0  0  1  1  0  0  1		, (CH)		"
1  0  1  1  0  0  0		- (DH)		"
0  1  1  1  0  0  0		. (EH)		"
1  1  1  1  0  0  1		/ (FH)		"
0  0  0  0  1  0  0		0 (10H)		Data (numeric)
1  0  0  0  1  0  1		1 (11H)		"
0  1  0  0  1  0  1		2 (12H)		"
1  1  0  0  1  0  0		3 (13H)		"
0  0  1  0  1  0  1		4 (14H)		"
1  0  1  0  1  0  0		5 (15H)		"
0  1  1  0  1  0  0		6 (16H)		"
1  1  1  0  1  0  1		7 (17H)		"
0  0  0  1  1  0  1		8 (18H)		"
1  0  0  1  1  0  0		9 (19H)		"
0  1  0  1  1  0  0		: (1AH)		Special
1  1  0  1  1  0  1		; (1BH)		"
0  0  1  1  1  0  0		< (1CH)		"
1  0  1  1  1  0  1		= (1DH)		"
0  1  1  1  1  0  1		> (1EH)		"
1  1  1  1  1  0  0		? (1FH) 	End Sentinel
0  0  0  0  0  1  0		@ (20H)		Special
1  0  0  0  0  1  1		A (21H)		Data (alpha)
0  1  0  0  0  1  1		B (22H)		"
1  1  0  0  0  1  0		C (23H)		"
0  0  1  0  0  1  1		D (24H)		"
1  0  1  0  0  1  0		E (25H)		"
0  1  1  0  0  1  0		F (26H)		"
1  1  1  0  0  1  1		G (27H)		"
0  0  0  1  0  1  1		H (28H)		"
1  0  0  1  0  1  0		I (29H)		"
0  1  0  1  0  1  0		J (2AH)		"
1  1  0  1  0  1  1		K (2BH)		"
0  0  1  1  0  1  0		L (2CH)		"
1  0  1  1  0  1  1		M (2DH)		"
0  1  1  1  0  1  1		N (2EH)		"
1  1  1  1  0  1  0		O (2FH)		"
0  0  0  0  1  1  1		P (30H)		"
1  0  0  0  1  1  0		Q (31H)		" 
0  1  0  0  1  1  0		R (32H)		"
1  1  0  0  1  1  1		S (33H)		"
0  0  1  0  1  1  0		T (34H)		"
1  0  1  0  1  1  1		U (35H)		"
0  1  1  0  1  1  1		V (36H)		"
1  1  1  0  1  1  0		W (37H)		"
0  0  0  1  1  1  0		X (38H)		"
1  0  0  1  1  1  1		Y (39H)		"
0  1  0  1  1  1  1		Z (3AH)		"
1  1  0  1  1  1  0		[ (3BH)		Special
0  0  1  1  1  1  1		\ (3DH)		Special
1  0  1  1  1  1  0		] (3EH)		Special
0  1  1  1  1  1  0		^ (3FH)		Field Separator
1  1  1  1  1  1  1		_ (40H)		Special

* 64 Character 7-bit Set
* 43 Alphanumeric Data Characters
* 3 Framing/Field Characters
* 18 Control/Special Characters

The two ANSI/ISO formats, ALPHA and BCD, allow a great variety of data to be stored on magstripes.
Most cards with magstripes use these formats, but occasionally some do not.
More about those lateron.

ANSI/ISO Track 1,2,3 Standards

Track	Name	Density		Format	Characters	Function
-----------------------------------------------------------------------------------
1	IATA	210 bpi		ALPHA	79		Read Name & Account
2	ABA	75 bpi		BCD	40		Read Account
3	THRIFT	210 bpi		BCD	107		Read Account & *Encode* Transaction 

This contains an explanation about the format of the three magnetic tracks in standard identification cards, particularly those used in financial transactions, i.e., credit and debit cards.

It is a summary of the international standards ISO-7813(tracks 1 and 2) and ISO-4909(track 3).

Track 1 (IATA)

Up to 79 ALPHA 7-bit (including parity) characters (alphanumeric) including SS,
 ES and LRC.
Read only.
It comprises the following fields (in this order): 
SS: Start Sentinel. 1 character: %.
FC: Format Code. 1 character (alphabetic only):
	A: Reserved for proprietary use of card issuer.
	B: Bank/financial. This is the format described here.
	C-M: Reserved for use by ANSI Subcommittee X3B10.
	N-Z: Available for use by individual card issuers.
PAN: Primary Account Number. Up to 19 digits:
	In accordance with the account numbering scheme in ISO 7812.
	It consists of the following parts:
		IIN: Issuer Identification Number. Up to 6 digits:
			It consists of the following parts:
			MII: Major Industry Identifier. Up to 2 digits:
				0: Reserved for future use by ISO/TC 68.
				00: Institutions other than card issuers.
				1: Airlines.
				2: Airlines and other future assignments.
				3: Travel and entertainment.
				4: Banking/financial.
				5: Banking/financial.
				59: Financial institutions not registered by ISO.
				6: Merchandising and banking.
				7: Petroleum.
				8: Telecommunications and other future assignments.
				89: Telecommunications administrations and private operating agencies.
				9: Reserved for national use.
			II: Issuer Identifier. Up to 5 digits:
				Identifies the issuer.
				In some cases the first digit indicates the length of the IIN
				 or the responsibility of its assignment outside of ISO.
				If MII = 9 then the first 3 digits should be the country code (CC).
		IAI: Individual Account Identification. Up to 12 digits:
			Assigned by the card issuing institution.
		CD: Check Digit. 1 digit:
			Calculated using the Luhn formula for computing modulus 10
			 "double-add-double" check digit: Double the value of alternate (odd) digits
			 starting by the least significant (first right hand) digit.
			Then add the individual digits of doubled (odd) numbers and even digits of
			 the original number.
			If the value ends in 0 then the check digit is 0.
			Otherwise subtract the value from the next higher number ending in 0
			 (tens complement of the unit digit).
			The result is the check digit.
			Example: If the account number without check digit is 1234 5678 9012 344 then
			 (8) + 4 + (6) + 2 + (2) + 0 + (1 + 8) + 8 + (1 + 4) + 6 + (1 + 0) + 4 + (6)
			  + 2 + (2) = 65, therefore the check digit is 70 - 65 = 5 and so the complete
			  account number is 1234 5678 9012 3445.
	MasterCard PAN is variable up to 16 digits and VISA is 13 or 16 digits, including check digit.
FS: Field Separator. 1 character: ^.
CC: Country Code. 3 digits:
	Only if PAN starts with 59 (MasterCard).
	Country codes are defined in ISO 3166: 724 for Spain, 840 for USA, etc.
NM: Name. 2-26 characters:
	Surname(s) (separated by space if necessary).
	Surname separator: /.
	First name(s) or initial(s) (separated by space if necessary).
	Period (when followed by title).
	Title (when used).
	If this field is not used the content will be an space followed by a surname separator (/).
FS: Field Separator. 1 character: ^.
ED: Expiry Date. 4 digits: YYMM.
	If this field is not used a FS will be in place.
	Required by MasterCard and VISA.
SC: Service Code. 3 digits:
	Digit 1 (most significant): Interchange and technology:
		0: Reserved for future use by ISO.
		1: Available for international interchange.
		2: Available for international interchange and with integrated circuit, which should be used for the financial transaction when feasible.
		3: Reserved for future use by ISO.
		4: Reserved for future use by ISO.
		5: Available for national interchange only, except under bilateral agreement.
		6: Available for national interchange only, except under bilateral agreement, and with integrated circuit, which should be used for the financial transaction when feasible.
		7: Not available for general interchange, except under bilateral agreement.
		8: Reserved for future use by ISO.
		9: Test.
	Digit 2: Authorization processing:
		0: Transactions are authorized following the normal rules.
		1: Reserved for future use by ISO.
		2: Transactions are authorized by issuer and should be online.
		3: Reserved for future use by ISO.
		4: Transactions are authorized by issuer and should be online, except under bilateral agreement.
		5: Reserved for future use by ISO.
		6: Reserved for future use by ISO.
		7: Reserved for future use by ISO.
		8: Reserved for future use by ISO.
		9: Reserved for future use by ISO.
	Digit 3 (least significant): Range of services and PIN requirements:
		0: No restrictions and PIN required.
		1: No restrictions.
		2: Goods and services only (no cash).
		3: ATM only and PIN required.
		4: Cash only.
		5: Goods and services only (no cash) and PIN required.
		6: No restrictions and require PIN when feasible.
		7: Goods and services only (no cash) and require PIN when feasible.
		8: Reserved for future use by ISO.
		9: Reserved for future use by ISO.
	If this field in not used a FS will be in place.
	Required by MasterCard and VISA.
PVV: Offset or PVV (PIN Verification Value). 5 digits:
	Required by MasterCard and VISA.
DD: Discretionary Data. Rest of characters:
	Reserved for proprietary use of card issuer.
ES: End Sentinel. 1 character: ?.
LRC: Longitude Redundancy Check. 1 character.

Track 2 (ABA)

Up to 40 BCD 5-bit (including parity) characters (numeric) including SS, ES and LRC.
Read only.
It comprises the following fields (in this order):
SS: Start Sentinel. 1 character: ;.
PAN: Primary Account Number. Up to 19 digits:
	In accordance with the account numbering scheme in ISO 7812.
	It consists of the following parts:
		IIN: Issuer Identification Number. Up to 6 digits:
			It consists of the following parts:
				MII: Major Industry Identifier. Up to 2 digits:
					0: Reserved for future use by ISO/TC 68.
					00: Institutions other than card issuers.
					1: Airlines.
					2: Airlines and other future assignments.
					3: Travel and entertainment.
					4: Banking/financial.
					5: Banking/financial.
					59: Financial institutions not registered by ISO.
					6: Merchandising and banking.
					7: Petroleum.
					8: Telecommunications and other future assignments.
					89: Telecommunications administrations and private operating agencies.
					9: Reserved for national use.
				II: Issuer Identifier. Up to 5 digits:
					Identifies the issuer. In some cases the first digit indicates the
					 length of the IIN or the responsibility of its assignment outside of ISO.
					If MII = 9 then the first 3 digits should be the country code (CC).
		IAI: Individual Account Identification. Up to 12 digits:
			Assigned by the card issuing institution.
		CD: Check Digit. 1 digit:
			Calculated using the Luhn formula for computing modulus 10
			 "double-add-double" check digit: Double the value of alternate (odd)
			 digits starting by the least significant (first right hand) digit.
			Then add the individual digits of doubled (odd) numbers and even digits
			 of the original number.
			If the value ends in 0 then the check digit is 0.
			Otherwise subtract the value from the next higher number ending in 0
			 (tens complement of the unit digit).
			The result is the check digit.
			Example: If the account number without check digit is 1234 5678 9012 344
			 then (8) + 4 + (6) + 2 + (2) + 0 + (1 + 8) + 8 + (1 + 4) + 6 + (1 + 0)
			 + 4 + (6) + 2 + (2) = 65, therefore the check digit is 70 - 65 = 5 and
			 so the complete account number is 1234 5678 9012 3445.
	MasterCard PAN is variable up to 16 digits and VISA is 13 or 16 digits
	 including check digit.
FS: Field Separator. 1 character: =.
CC: Country Code. 3 digits:
	Only if PAN starts with 59 (MasterCard).
	Country codes are defined in ISO 3166: 724 for Spain, 840 for USA, etc.
ED: Expiry Date. 4 digits: YYMM.
	If this field is not used a FS will be in place.
	Required by MasterCard and VISA.
SC: Service Code. 3 digits:
	Digit 1 (most significant): Interchange and technology:
		0: Reserved for future use by ISO.
		1: Available for international interchange.
		2: Available for international interchange and with integrated circuit, which should be used for the financial transaction when feasible.
		3: Reserved for future use by ISO.
		4: Reserved for future use by ISO.
		5: Available for national interchange only, except under bilateral agreement.
		6: Available for national interchange only, except under bilateral agreement, and with integrated circuit, which should be used for the financial transaction when feasible.
		7: Not available for general interchange, except under bilateral agreement.
		8: Reserved for future use by ISO.
		9: Test.
	Digit 2: Authorization processing:
		0: Transactions are authorized following the normal rules.
		1: Reserved for future use by ISO.
		2: Transactions are authorized by issuer and should be online.
		3: Reserved for future use by ISO.
		4: Transactions are authorized by issuer and should be online, except under bilateral agreement.
		5: Reserved for future use by ISO.
		6: Reserved for future use by ISO.
		7: Reserved for future use by ISO.
		8: Reserved for future use by ISO.
		9: Reserved for future use by ISO.
	Digit 3 (least significant): Range of services and PIN requirements:
		0: No restrictions and PIN required.
		1: No restrictions.
		2: Goods and services only (no cash).
		3: ATM only and PIN required.
		4: Cash only.
		5: Goods and services only (no cash) and PIN required.
		6: No restrictions and require PIN when feasible.
		7: Goods and services only (no cash) and require PIN when feasible.
		8: Reserved for future use by ISO.
		9: Reserved for future use by ISO.
	If this field in not used a FS will be in place.
	Required by MasterCard and VISA.
PVV: Offset or PVV (PIN Verification Value). 5 digits:
	Required by MasterCard and VISA.
DD: Discretionary Data. Rest of characters:
	Reserved for proprietary use of card issuer.
ES: End Sentinel. 1 character: ?.
LRC: Longitude Redundancy Check. 1 character.

Track 3 (THRIFT-TTS)

Up to 107 BCD 5-bit (including parity) characters (numeric) including SS, ES and LRC.
Read and write.
It comprises the following fields (in this order): 
SS: Start Sentinel. 1 character: ;.
FC: Format Code. 2 digits:
	00: Not valid for international interchange.
	01-02: Bank/financial. These are the formats described here.
	03-19: Reserved for future use by ISO/TC 68.
	20-89: Reserved for future use by ISO/TC 95 SC 17.
	90-99: Reserved for proprietary use of card issuer, but not for international interchange.
PAN: Primary Account Number. Up to 19 digits:
	In accordance with the account numbering scheme in ISO 7812.
	It consists of the following parts:
	IIN: Issuer Identification Number. Up to 6 digits:
		It consists of the following parts:
			MII: Major Industry Identifier. Up to 2 digits:
				0: Reserved for future use by ISO/TC 68.
				00: Institutions other than card issuers.
				1: Airlines.
				2: Airlines and other future assignments.
				3: Travel and entertainment.
				4: Banking/financial.
				5: Banking/financial.
				59: Financial institutions not registered by ISO.
				6: Merchandising and banking.
				7: Petroleum.
				8: Telecommunications and other future assignments.
				89: Telecommunications administrations and private operating agencies.
				9: Reserved for national use.
			II: Issuer Identifier. Up to 5 digits:
				Identifies the issuer.
				In some cases the first digit indicates the length of the IIN or the
				 responsibility of its assignment outside of ISO.
				If MII = 9 then the first 3 digits should be the country code (CC).
	IAI: Individual Account Identification. Up to 12 digits:
		Assigned by the card issuing institution.
	CD: Check Digit. 1 digit:
		Calculated using the Luhn formula for computing modulus 10
		 "double-add-double" check digit: Double the value of alternate (odd)
		 digits starting by the least significant (first right hand) digit.
		Then add the individual digits of doubled (odd) numbers and even digits
		 of the original number.
		If the value ends in 0 then the check digit is 0.
		Otherwise subtract the value from the next higher number ending in 0
		 (tens complement of the unit digit).
		The result is the check digit.
		Example: If the account number without check digit is 1234 5678 9012 344
		 then (8) + 4 + (6) + 2 + (2) + 0 + (1 + 8) + 8 + (1 + 4) + 6 + (1 + 0)
		 + 4 + (6) + 2 + (2) = 65, therefore the check digit is 70 - 65 = 5 and
		 so the complete account number is 1234 5678 9012 3445.
	MasterCard PAN is variable up to 16 digits and VISA is 13 or 16 digits, including check digit.
	If track 3 is to be used together with track 2 then PAN is an optional field.
FS: Field Separator. 1 character: =.
CC: Country Code. 3 digits:
	Country codes are defined in ISO 3166: 724 for Spain, 840 for USA, etc.
	If this field in not used a FS will be in place.
CuC: Currency Code. 3 digits:
	Currency codes are defined in ISO-4217:724 for Spanish peseta, 840 for US dollar, etc.
	If 3 zeros (000) are written in this field it means card not valid for international interchange.
CE: Currency Exponent. 1 digit:
	0-5: Power of ten by which multiply the currency amount fields (AA and AR)
	 to get their actual values in the currency of the CuC field.
AA: Amount Authorized per cycle. 4 digits:
	Maximum amount of money permitted in one cycle.
	If 4 zeros (0000) are written in this field it means card not valid for
	 charge operations (no debit).
AR: Amount Remaining this cycle. 4 digits:
	Maximum amount of money permitted in this cycle.
	This field is dynamic, it is initialized with the value of the AA field the
	 first time the card is used in a new cycle.
	Then it is modified accordingly.
CB: Cycle Begin (Validity Date). 4 digits:
	Date in which actual cycle began.
	The format is YDDD where Y stands for the least significant digit of the year
	 and DDD is the day of the year (001 to 366).
	The field must be updated each time a new cycle begin.
	Alternatively this field may indicate the date from which the card is valid.
CL: Cycle Length. 2 digits:
	00: Infinite, AR should be decremented but never reset.
	01-79: Number of days.
	80: Cycle begin each 7 days.
	81: Cycle begin each 14 days.
	82: Cycle begins each 1st and 15th days of every month.
	83: Cycle begins the day of the month specified in CB of every month.
	84: Cycle begins the day of the month specified in CB of every third month.
	85: Cycle begins the day of the month specified in CB of every sixth month.
	86: Cycle begins the day of the year specified in CB of every year.
	87-89: Reserved for future use by ISO/TC 68.
	90-99: Reserved for proprietary use of card issuer, but not for international interchange.
	This field represents the duration of the cycle for which the AA limit holds.
RC: Retry Count. 1 digit:
	Number of remaining PIN trials. It is initialized to 3 and reduced by one unit after every wrong PIN entered. It is reset to 3 after a successful PIN introduction. When this field reaches 0 the card is invalid for any interchange purpose.
PINCP: PIN Control Parameters (PINPARM). 6 digits:
	If FC = 01 the two first digits represent the algorithm used to calculate PIN, where 00-09 mean private algorithm, 10-19 mean DEA and values 20 to 99 are reserved for future use by ISO/TC 68. Next 4 digits are PIN offset, a complementary value of PIN so customers can change their PIN, or PVV.
	If FC = 02 the first digit represents the algorithm used to calculate PIN, where 0 means private algorithm, 1 means DEA and values 2 to 9 are reserved for future use by ISO/TC 68. The second digit represents a key for the algorithm. Next 4 digits are PIN offset, a complementary value of PIN so customers can change their PIN, or PVV.
	If this field is not used a FS will be in place.
IC: Interchange Control. 1 digit:
	0: No restriction.
	1: Not available for international interchange.
	2-8: Limited interchange, only local use and under agreement.
	9: Limited interchange, recommended for test cards.
PANSR: PAN Service Restriction. 2 digits:
	The first digit defines the type of account:
		0: Associated account number not encoded on track.
		1: Savings account.
		2: Current or checking account.
		3: Credit card account.
		4: Generic or universal account.
		5: Interest-bearing current or checking account.
		6-8: Reserved for future use by ISO/TC 68.
		9: Reserved for card issuer's internal use, not for interchange.
	The second digit defines the service restrictions:
		0: No restrictions.
		1: No cash dispense.
		2: No point of sale (POS) transaction.
		3: No cash dispense and no POS transaction.
		4: Authorization required.
		5-7: Reserved for future use by ISO/TC 68.
		8-9: Reserved for card issuer's internal use, only local use and under agreement.
FSANSR: FSAN Service Restriction. 2 digits:
	Same values and meaning as for PANSR field.
SSANSR: SSAN Service Restriction. 2 digits:
	Same values and meaning as for PANSR field.
ED: Expiry Date. 4 digits: YYMM.
	If this field is not used a FS will be in place.
CSN: Card Sequence Number. 1 digit:
	Allows to distinguish among different cards with the same PAN. It is incremented by one unit in any additional card.
	If FC = 02 and a FS is in place it means that field ACSN is present.
CScN: Card Security Number. 9 digits:
	The first digit represents the algorithm used to calculate a verification value to validate the information on the magnetic track against the embossed characters, where 0-4 are available for national use, 5-8 are available for international security methods given by ISO/TC 68, and 9 is reserved for private use. Next 8 digits are the verification value.
	If this field in not used a FS will be in place.
FSAN: First Subsidiary Account Number. Variable number of digits:
	This is an optional field.
FS: Field Separator. 1 character: =.
SSAN: Second Subsidiary Account Number. Variable number of digits:
	This is an optional field.
FS: Field Separator. 1 character: =.
RM: Relay Marker. 1 digit:
	0: Include AD and DD fields in transactions messages.
	1: Do not include AD field in transactions messages.
	2: Do not include DD field in transactions messages.
	3-9: Invalid.
CCD: Crypto Check Digits. 6 digits:
	A validation value which permits integrity verification of the magnetic stripe content.
	If this field in not used a FS will be in place.
AD: Additional Data. Rest of characters:
	Optional field reserved for proprietary use of card issuer if FC = 01. 
	If FC = 02 the following subfields are required:
TD: Transaction Date. 4 digits:
	Date of last cash dispense. The format is YDDD where Y stands for the least significant digit of the year and DDD is the day of the year (001 to 366).
	If this field in not used a FS will be in place.
AVV: Additional Verification Value(s). 8 digits:
	Validation of the PIN or two additional PINs corresponding to different keys of the same algorithm. It can be an eight digit value, two four digit numbers or, in connection with the last four digits of the PINCP field, two six digit numbers.
	If this field in not used a FS will be in place.
ACSN: Alternative Card Sequence Number. 3 digits:
	Same purpose as CSN field but it allows for a maximum of 1000 different cards instead of 10.
	If this field in not used a FS will be in place.
INIC: International Network Identification Code. 3 digits:
	Code for identification of an international group of issuers, when the IIN can not be used. It is equivalent to the term Network International Identifier used in ISO 8583.
	If this field in not used a FS will be in place.
DD: Discretionary Data. Rest of characters:
	Optional field reserved for proprietary use of card issuer.
ES: End Sentinel. 1 character: ?.
LRC: Longitude Redundancy Check. 1 character.

*/

/* Caja de Madrid ATM card (VISA logo):

Embossing:

Card holder : L. PADILLA
Card number*: 1234 5678 9012 3445
Expiration  : 01/99

*The card number (PAN) uses, as most of the credit and debit cards, the Luhn Check Digit Algorithm. Valid numbers must comply with the following rule. If the card number has an even number of digits, then the adding up of the even numbered digits plus the odd numbered digits doubled (minus 9 if the doubled digit is greater than 9) has to be multiple of 10. If the card number has an odd number of digits, then the same applies but doubling even (instead of odd) numbered digits. Using the example above: 2 x 1 + 2 + 2 x 3 + 4 + 2 x 5 - 9 + 6 + 2 x 7 - 9 + 8 + 2 x 9 - 9 + 0 + 2 x 1 + 2 + 2 x 3 + 4 + 2 x 4 + 5 = 70 and therefore the number in the example is a valid number for a credit or debit card. Actually is the other way round, the last digit of the card number is calculated so that the whole number complies with Luhn Check, therefore the last digit is called check digit.

Track 1:

%B1234567890123445^PADILLA/L.                ^99011200000000000000**XXX******?*
^^^               ^^                         ^^   ^       ^         ^        ^^
|||_ Card number  ||_ Card holder            ||   |       |         |_ CVV** ||_ LRC
||_ Format code   |_ Field separator         ||   |       |                  |_ End sentinel
|_ Start sentinel           Field separator _||   |       |_ Discretionary data
                                  Expiration _|   |_ Service code

Track 2:

;1234567890123445=99011200XXXX00000000?*
^^               ^^   ^   ^           ^^
||_ Card number  ||   |   |_ Encrypted||_ LRC
|_ Start sentinel||   |      PIN***   |_ End sentinel
                 ||   |_ Service code
Field separator _||_ Expiration

Track 3:

;011234567890123445=724724100000000000030300XXXX040400099010=************************==1=0000000000000000?*
^^ ^               ^^  ^  ^            ^ ^  ^   ^^ ^   ^    ^^                       ^^^^^               ^^
|| |               ||  |  |_ Currency  | |  |   || |   |    ||_ First subsidiary     |||||_ Additional   ||
|| |               ||  |     exponent  | |  |   || |   |    |   account number (FSAN)||||   data         ||
|| |_ Card number  ||  |_ Currency     | |  |   || |   |    |_ Field separator       ||||_ Field         ||_ LRC
||_ Format code    ||     (Peseta)     | |  |   || |   |_ Expiration                 |||   separator     |_ End sentinel
|_ Start sentinel  ||_ Country (Spain) | |  |   || |_ FSAN service restriction       |||_ Relay marker
                   |_ Field separator  | |  |   ||_ PAN service restriction          ||_ Field separator
                         Cycle length _| |  |   |_ Interchange control               |_ Field separator
                            Retry count _|  |_ Encrypted PIN***

The CVV (Card Verification Value) is a cryptographic signature of the card number, the expiration date and the service code to verify the integrity of these data in the track. It is calculated with an algorithm similar to that of PIN encryption. *The PIN (Personal Identification Number) is basically encrypted as follows. The card number is taken as an hexadecimal number and is encrypted with the DES algorithm using a secret key, which is called the “PIN key”. The first four digits are decimalized (i.e., A = 0, B = 1, …) and are called the “natural PIN”. An offset is added (without carry) to the natural PIN in order to obtain the customer PIN. The customer PIN may be changed but the natural PIN cannot. The offset is what is written in track 3 and I called the “encrypted PIN”. Here you have an example: Card number: 1234567890123445hex input for DES. PIN key: 0123456789ABCDEFhex key for DES. Encrypted card number: 9A466AD30DFE0381hex output from DES. Natural PIN: 9046. Offset: 2298 (this number is written on track 3). Customer PIN: 1234. See also the original VISA scheme and a discussion on other systems. See the two much more detailed and complete documents linked in my main page for magnetic stripe cards. */ /* Caja Madrid VISA or VISA Electron card:

Embossing or printing:

Card holder: L. PADILLA
Card number: 1234 5678 9012 3445
Expiration : 01/99

Track 1:

%B1234567890123445^PADILLA/L.                ^99011X100000*000000000XXX000000?*
^^^               ^^                         ^^   ^       ^         ^        ^^
|||_ Card number  ||_ Card holder            ||   |       |         |_ CVV   ||_ LRC
||_ Format code   |_ Field separator         ||   |       |                  |_ End sentinel
|_ Start sentinel           Field separator _||   |       |_ Discretionary data
                                  Expiration _|   |_ Service code: 101 for VISA and 121 for VISA Electron

Track 2:

;1234567890123445=99011X10XXXXXXX00000?*
^^               ^^   ^   ^   ^       ^^
||_ Card number  ||   |   |   |_ CVV  ||_ LRC
|_ Start sentinel||   |   |           |_ End sentinel
Field separator _||   |   |_ Encrypted PIN (except if duplicate card)
      Expiration _|   |_ Service code: 101 for VISA and 121 for VISA Electron

Track 3:

;011234567890123445=724724000000000****00300XXXX020200099010=********************==1=100000000000000000**?*
^^ ^               ^^  ^           ^     ^  ^   ^^ ^   ^    ^^                   ^^^^^                   ^^
|| |               ||  |_ Currency |     |  |   || |   |    ||_ FSAN             |||||                   ||
|| |_ Card number  ||     (Peseta) |     |  |   || |   |    |_ Field separator   |||||_ Additional data  ||_ LRC
||_ Format code    ||_ Country     |     |  |   || |   |_ Expiration             ||||_ Field separator   |_ End sentinel
|_ Start sentinel  |   (Spain)     |     |  |   || |_ FSAN service restriction   |||_ Relay marker
                   |_ Field        |     |  |   ||_ PAN service restriction      ||_ Field separator
                      separator    |     |  |   |_ Interchange control           |_ Field separator
                    Validity date _|     |  |_ Encrypted PIN (except if duplicate card)
              (except if duplicate card) |_ Retry count

*/ /* Uno-e VISA Electron card:

Printing:

Card holder: L. PADILLA
Card number: 1234 5678 9012 3445
Expiration : 01/99

Track 1:

%B1234567890123445^PADILLA/L.                ^99011211XXXX*000000**0XXX0**000?*
^^^               ^^                         ^^   ^  ^^   ^         ^        ^^
|||_ Card number  ||_ Card holder            ||   |  ||   |_ Discr. |_ CVV   ||_ LRC
||_ Format code   |_ Field separator         ||   |  ||      data            |_ End sentinel
|_ Start sentinel           Field separator _||   |  ||_ PVV*
                                  Expiration _|   |  |_ PVV key indicator
                                                  |_ Service code

Track 2:

;1234567890123445=99011211XXXXXXX00***?*
^^               ^^   ^  ^^   ^       ^^
||_ Card number  ||   |  ||   |_ CVV  ||_ LRC
|_ Start sentinel||   |  ||_ PVV*     |_ End sentinel
Field separator _||   |  |_ PVV key indicator
      Expiration _|   |_ Service code

Track 3:

;011234567890123445=000978100000000****8330*0000920000099010=************************==1=0000000*00000000?*
^^ ^               ^   ^  ^        ^   ^ ^      ^^     ^    ^^                       ^^^^^               ^^
|| |               |   |  |_ Curr. |   | |_Retry||     |    ||_ FSAN                 |||||_ Additional   ||_ LRC
|| |_ Card number  | Curr.   expon.|   |   count||     |    |_ Field separator       ||||   data         |_ End sentinel
||_ Format code    | (Euro)        |   |        ||     |_ Expiration                 ||||_ Field separator
|_ Start sentinel  |_ Field        |   |_ Cycle ||_ PAN service restriction          |||_ Relay marker
                      separator    |      length|_ Interchange control               ||_ Field separator
                    Validity date _|                                                 |_ Field separator

*The PVV (PIN Verification Value) is another way of PIN encryption. It is calculated with an algorithm similar to that described above. */ /* Caja Bilbao Vizcaya ATM card (MasterCard logo):

Embossing:

Card holder: L. PADILLA
Card number: 1234 5678 9012 3445
Expiration : 01/99

Track 1:

%B1234567890123445^PADILLA/L.                ^990110100000000XXX****XXX******?*
^^^               ^^                         ^^   ^       ^  ^      ^        ^^
|||_ Card number  ||_ Card holder            ||   |       |  |      |_ CVV   ||_ LRC
||_ Format code   |_ Field separator         ||   |       |  |_ Number       |_ End sentinel
|_ Start sentinel           Field separator _||   |       |_ Discretionary data
                                  Expiration _|   |_ Service code

Track 2:

;1234567890123445=990110100000XXXXXX00?*
^^               ^^   ^       ^  ^    ^^
||_ Card number  ||   |  CVV _|  |    ||_ LRC
|_ Start sentinel||   |  Number _|    |_ End sentinel
                 ||   |_ Service code
Field separator _||_ Expiration

Track 3:

;011234567890123445=7247241000000000000001000000040400099010=************************==0=0002000000******?*
^^ ^               ^^  ^  ^              ^      ^^ ^   ^    ^^                       ^^^^^               ^^
|| |_ Card number  ||  |  |_ Currency    |      || |   |    ||_ First subsidiary     |||||_ Additional   ||
||_ Format code    ||  |     exponent    |      || |   |    |   account number (FSAN)||||   data         ||
|_ Start sentinel  ||  |_ Currency       |      || |   |    |_ Field separator       ||||_ Field         ||_ LRC
  Field separator _||     (Peseta)       |      || |   |_ Expiration                 |||   separator     |_ End sentinel
                    |_ Country (Spain)   |      || |_ FSAN service restriction       |||_ Relay marker
                            Retry count _|      ||_ PAN service restriction          ||_ Field separator
                                                |_ Interchange control               |_ Field separator

*/ /* Sanitas (private sanitary coverage) card:

Embossing:

Card holder: L. PADILLA
Card number: 999999 8888 777 666 5
Validity   : 01/98 - 02/99

Track 1:

%BXXXXXX99999900000888877=L. PADILLA                    =666599029801?*
^^^     ^          ^     ^^                             ^^   ^       ^^
|||     |          |     ||_ Card holder                ||   |       ||_ LRC
|||     |          |     |_ Field separator             ||   |       |_ End sentinel
|||     |          |_ Card number(2)                    ||   |_ Validity
|||     |_ Card number(1)              Field separator _||_ Card number(3)
|||_ Number
||_ Format code
|_ Start sentinel

Track 2:

;XXXXXX999999000008888777=666990259801?*
^^     ^          ^      ^^  ^   ^^   ^^
||     |          |      ||  |   ||   ||_ LRC
||     |          |      ||  |   ||   |_ End sentinel
||     |          |      ||  |   ||_ Validity(2)
||     |          |      ||  |   |_ Card number(4)
||     |          |      ||  |_ Validity(1)
||     |          |      ||_ Card number(3)
||     |          |      |_ Field separator
||     |          |_ Card number(2)
||     |_ Card number(1)
||_ Number
|_ Start sentinel

Track 3:

Empty (all zeros)

*/ /* Social security card:

Embossing:

Card holder: L. PADILLA
Card number: 999999 PDVS123456789012
Expiration : 03/99

Track 1:

%B999999^PDVS123456789012^PADILLA L.                    ^0X0000399           ?*
^^^     ^^^^^^           ^^                             ^ ^   ^              ^^
|||     ||||||_ Card     ||_ Card holder                | |   |_ Expiration  ||_ LRC
|||     |||||   number(2)|_ Field separator (formerly =)| |                  |_ End sentinel
|||     |||||_ 3rd letter from 2nd surname              | |_ = 1 -> Non pensioner
|||     ||||_ 1st letter from 2nd surname               |    = 2 -> Pensioner
|||     |||_ 3rd letter from 1st surname                |_ Field separator (formerly =)
|||     ||_ 1st letter from 1st surname
|||     |_ Field separator (formerly =)
|||_ Card number(1)
||_ Format code
|_ Start sentinel

Track 2:

;999999554749123456789012=00X990300000?*
^^     ^  ^  ^           ^  ^^        ^^
||     |  |  |_ Card     |  ||        ||_ LRC
||     |  |     number(2)|  ||        |_ End sentinel
||     |  |              |  ||_ Expiration
||     |  |              |  |_ See above
||     |  |              |_ Field separator
||     |  |_ = 30 x (#V - 30) + #S - 22, where #X means decimal value of character X in the ALPHA format (#A = 33, #B = 34, ...)
||     |_ = 30 x (#P - 30) + #D - 22, where P, D, V and S come from the card number (see above)
||_ Card number(1)
|_ Start sentinel

Track 3:

Empty (all zeros) or not present

*/ /* Vitalicio-Salud (private sanitary coverage) card:

Embossing:

Card holder: L. PADILLA
Card number: 0123456789
Validity   : 04/99 - 12/99

Track 1:

%0123456789L. PADILLA                ?*
^^         ^                         ^^
||         |_ Card holder            ||_ LRC
||_ Card number                      |_ End sentinel
|_ Start sentinel

Track 2:

;0123456789?*
^^         ^^
||_ Card   ||_ LRC
|   number |_ End sentinel
|_ Start sentinel

Track 3:

Empty (all zeros)

*/ /* Ciudad de las Artes y las Ciencias pass ticket:

Printing:

Date: 16/12/00 20:00
Number: 010100381781

Track 1:

Not present

Track 2:

;012001120100381781?*
^ ^       ^        ^^
| |_ Date?|        ||_ LRC
|         |        |_ End sentinel
|         |_ Partial number
|_ Start sentinel

Track 3:

Not present

*/ /* Graphispag93 exhibitor ID card:

Printing:

Card holder: RUEDA, J

Track 1:

%RUEDA, J?*
^^       ^^
||       ||_ LRC
||       |_ End sentinel
||_ Card holder
|_ Start sentinel

Track 2:

Not present

Track 3:

Not present

*/ /* Carrefour gas station discount ticket:

Printing:

None

Track 1:

Not present

Track 2:

;9999989999999999=01015990000000000000?*
^                ^                    ^^
|_ Start sentinel|_ Field separator   ||_ LRC
                                      |_ End sentinel

Track 3:

Not present

*/ /* Madrid public parking ticket:

Printing:

Date: 14:31 06-02-98

Track 1:

Not present

Track 2:

;11431060298?*
^ ^         ^^
| |_ Date   ||_ LRC
|_ Start    |_ End sentinel
   sentinel

Track 3:

Not present

*/ /* Parque Ferial Juan Carlos I parking ticket:

Printing:

Date: 27/02/2003 13:32:05
String: 01044 9 35397 P01

Track 1:

Not present

Track 2:

;304601=0534177205044000000000000100?*
^      ^  ********^                 ^^
|      |          |_ Digits 3 to 5  ||
|      |             of string      ||
|      |_ Field separator           ||_ LRC
|_ Start sentinel                   |_ End sentinel

Track 3:

Not present

*/ /* Val Thorens parking card:

Printing:

Number  : 11069
Parking : P0
Validity: 02/01/96 - 06/01/96

Track 1:

Not present

Track 2:

;>4155594>4713000110=11106909912310000?*
^                   ^ ^               ^^
|_ Start sentinel   | |_ Number       ||_ LRC
                    |_ Field separator|_ End sentinel

Track 3:

Not present

*/ /* Read more at: http://www.epanorama.net/documents/smartcard/magcard.html */