Eli5: How do they know if it is a valid card number?

334 views

When you are asked to input your card information online, how is it that some websites can automatically know if you input an invalid number and others cannot, before payment is processed?Example: as soon as I typed the last number of my card wrong, it went red and would not allow me to continue before I corrected it.

In: 340

8 Answers

Anonymous 0 Comments

A lot of answers here are talking about it, but none specifically mentioning the actual algorithm and how it works. It’s called the Luhn algorithm, and credit cards must use it. It is a very simple algorithm to run it and see if the number you input passes. If it doesn’t, it’s not a real number. That said, there are plenty of numbers that CAN pass which aren’t valid, 4444333322221111 just as a simple example. So passing the Luhn check does not guarantee it is a good number, it just means it passes a basic test so they can then send it on for actual processing.

https://en.m.wikipedia.org/wiki/Luhn_algorithm

You are viewing 1 out of 8 answers, click here to view all answers.