What is the Luhn Algorithm
A Luhn algorithm is an algorithm used to validate a credit card number or other identifying numbers, such as Social Security numbers. The Luhn algorithm, also called the Luhn formula or modulus 10, checks the sum of the digits in the card number and indicates whether the sums equal what is expected or if there is an error in the number sequence. After working through the algorithm, if the total modulus 10 equals zero, then the number is valid according to the Luhn method.
While the algorithm can be used to verify other identification numbers, it is most commonly associated with credit card verification. The algorithm works for all major credit cards.
BREAKING DOWN Luhn Algorithm
The credit card validation process requires businesses and credit card companies to be able to encrypt and decrypt sensitive financial information about the card, the issuer, and the cardholder nearly instantaneously. The volume of credit card transactions complicates this process and the companies party to these transactions look for ways to limit the amount of resources required to verify the transactions as much as they can. One way that they can speed up the verification process is to use the Luhn algorithm. The Luhn algorithm is especially helpful as more transactions are done online, where data breaches can be easier to make.
The Luhn algorithm is not designed to protect the security of the parties involved in a credit card transaction as much as it is designed to check for errors made in the transmission of card numbers. For example, a cardholder may type in the wrong digit while making a purchase online. Rather than go through the entire verification process only to determine that the number was mistyped, the algorithm checks the digits earlier in the process and returns an error message if something is amiss.
To determine whether a credit card number is valid, the sum of all of the digits, but not the check digit, is first calculated to find the units digit. The difference between the units digit of the resulting sum and the number ten is the estimated check digit. If the estimated check digit and the actual check digit are the same then the card has been validated.
History of the Luhn Algorithm
The LUHN formula algorithm was actually developed 1960s by a group of mathematicians. After its conception, the algorithm was adopted for use initially by credit card companies. However, because the algorithm is considered public domain, anyone can, in theory, access and utilize it.