Credit cards use the Luhn Check DigitAlgorithm. The main purpose of the Luhn Check Digit Algorithm is to catch data entry errors, but it does double duty here as a weak security tool.
The Luhn Check Digit Algorithm
For a card with an even number of digits, double every odd numbered digit (1st digit, 3rd digit, 5th digit, etc…) and subtract 9 if the product is greater than 9.
Add up all the even digits (2nd digit, 4th digit, 6th digit, etc…) as well as the doubled-odd digits, and the result must be a multiple of 10 or it’s not a valid card.
If the card has an odd number of digits, perform the same addition doubling the even numbered digits instead.
Add up all the even digits (2nd digit, 4th digit, 6th digit, etc…) as well as the doubled-odd digits, and the result must be a multiple of 10 or it’s not a valid card.
If the card has an odd number of digits, perform the same addition doubling the even numbered digits instead.
No comments :
Post a Comment