We were low on kitty litter and soy milk, so I made a late night jaunt down to the Hadley Stop & Shop to pick up a few things. Going through the checkout line, I slid my Florence Savings Bank MasterCard through the scanner and was greeted with the message, “Invalid Magnetic Stripe Format.” I tried again – same result. The soy milk was getting warm and a queue was building up behind me. What to do?
The cashier noticed my consternation and handed me a plastic bag. When I shrugged stupidly she snatched my credit card, put it inside the bag and swiped it through the reader. Bingo! I saw the reassuring words, “Debit or Credit?”
I had just observed a workaround that is apparently fairly well known among the cash register community. When a card is scratched or somehow has bad chemistry with its reader, it can fail its parity check, a common software error detection technique. The addition of the layer of plastic above the magnetic strip dampens the magnetic noise that is responsible for the bad reading. A piece of scotch tape reportedly works well, too.
For 16-digit Visa and MasterCard numbers, the parity check algorithm looks like this:
- Add up the digits in odd positions (i.e. 1st, 3rd, 5th, …, 15th) and multiply the sum by two. Call the result ODDSUMDOUBLED.
- Add up all the digits in even positions (i.e. 2nd, 4th, 6th, …, 16th). Call this result EVENSUM.
- Go back to the set of odd-position digits that you added up in Step One. Count how many of these digits are greater than 4 and call this BIGODDCOUNT.
- Add up the numbers calculated in the first three steps. Call the sum CHECKSUM:
CHECKSUM = ODDSUMDOUBLED + EVENSUM + BIGODDCOUNT.
CHECKSUM must end in “0”. If it doesn’t the credit card number is invalid.
The card's final digit is called a check digit and is there is only one value for it that will enable the validation to work. Find a more detailed description at Anatomy of a Credit Card. If you are exceedingly curious or perhaps a sodoku fiend, pull out your wallet and validate your own card.