Platon Technologies
neprihlásený Prihlásiť Registrácia
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 18. jún 2024
O nás
Otvorený softvér
Index  »  Dev Resources  »  Credit card digits check

How to check digits in credit card validation

Autor: Hal Stiles | Sekcia: Dev Resources | Dátum: 2005-06-25

This document outlines procedures and algorithms for Verifying the accuracy and validity of credit card numbers. Most credit card numbers are encoded with a "Check Digit". A check digit is a digit added to a number (either at the end or the beginning) that validates the authenticity of the number.

A simple algorithm is applied to the other digits of the number which yields the check digit. By running the algorithm, and comparing the check digit you get from the algorithm with the check digit encoded with the credit card number, you can verify that you have correctly read all of the digits and that they make a valid combination.

Possible uses for this information:

  • When a user has keyed in a credit card number (or scanned it) and you want to validate it before sending it our for debit authorization.
  • When issuing cards, say an affinity card, you might want to add a check digit using the MOD 10 method.

Prefix, Length, and Check Digit Criteria

Here is a table outlining the major credit cards that you might want to validate.

CARD TYPE Prefix Length Check digit algorithm
MASTERCARD 51-55 16 mod 10
VISA 4 13, 16 mod 10
AMEX 34 37 15 mod 10
Diners Club / Carte Blanche 300-305 36 38 14 mod 10
Discover 6011 16 mod 10
enRoute 2014 2149 15 any
JCB 3 16 mod 10
JCB 2131 1800 15 mod 10

LUHN Formula (Mod 10) for Validation of Primary Account Number

The following steps are required to validate the primary account number:

Step 1: Double the value of alternate digits of the primary account number beginning with the second digit from the right (the first right--hand digit is the check digit.)

Step 2: Add the individual digits comprising the products obtained in Step 1 to each of the unaffected digits in the original number.

Step 3: The total obtained in Step 2 must be a number ending in zero (30, 40, 50, etc.) for the account number to be validated.

For example, to validate the primary account number 49927398716:

Step 1:

        4 9 9 2 7 3 9 8 7 1 6
         x2  x2  x2  x2  x2 
         18   4   6  16   2

Step 2:

4 +(1+8)+ 9 + (4) + 7 + (6) + 9 +(1+6) + 7 + (2) + 6

Step 3: Sum = 70 => Card number is validated

Note: Card is valid because the 70/10 yields no remainder.


The great folks at ICVERIFY are the original source of this data, I only formatted it in HTML.

If you are in the market, I wrote a set of FoxPro modules for Windows/Dos that interface nicely with ICVERIFY in a multi-user LAN setup. You just set up ICVERIFY on a single station, and all stations on the LAN can authorize credit cards with a single FOXBASE function call. Of course, you have to license ICVERIFY by the node, but it is very reasonable. I also wrote a couple of simple functions to perform pre-authorization, card screening, etc.

Here is a Microsoft Excel worksheet that will validate a number for you.

Horace Vallas made a NeoWebScript (Tcl really) procedure that implements it. Check it out at

Because I get at least a letter a week regarding this routine, here are some additional helpful notes:

Make sure that you:

  1. Have started with the rightmost digit (including the check digit) (figure odd and even based upon the rightmost digit being odd, regardless of the length of the Credit Card.) ALWAYS work right to left.
  2. The check digit counts as digit #1 (assuming that the rightmost digit is the check digit) and is not doubled.
  3. Double every second digit (starting with digit # 2 from the right).
  4. Remember that when you double a number over 4, (6 for example) you don't add the result to your total, but rather the sum of the digits of the result (in the above example 6*2=12 so you would add 1+2 to your total (not 12).
  5. Always include the Visa or M/C/ prefix.

Article was originally released on the Hal Stiles webpage server and in the Platon.SK content management system it is published with author and host administrator agreeement.

Čo je Platón?
Platón bol veľmi doležitý filozof starovekého Grécka, študent Sokratesa a učiteľ Aristotela. viac info...

Platon Group zastrešuje slovenskú skupinu vývojárov otvoreného softvéru. Vyvíja, spravuje, dokumentuje niekoľko úspešných open-source projektov.

Platon Technologies, s.r.o. je mladá a dynamicky rozvíjajúca sa spoločnosť, ktorá má za cieľ prinášať otvorené technológie do komerčnej a verejnej sféry.

Podporte nás

Výkonný webhosting
a multihosting

Platon Webhosting

Super rýchle servery
a profesionálna administrácia

Virtuálne, dedikované a manažované servery

Diskusia k článku
daniel jerry i need credit cad 2006-02-02 05:37
Nepto     RE: i need credit cad 2006-02-12 12:32
nike air max shoes         RE: i need credit cad 2011-03-31 08:24
jokes         RE: i need credit cad 2011-10-07 20:29
Samanatha Rose         RE: i need credit cad 2020-05-08 01:31
felix i need credit card 2006-06-14 17:07
Nepto     RE: i need credit card 2009-02-25 22:14
Johns 2020-05-21 21:01
Best nursing writing services Best nursing writing services 2020-12-22 10:30
techgrama how to 2021-03-28 11:42
jacksparrow checkout cool memes generator 2021-04-12 13:09
minika thank for share 2021-06-25 06:08
Sumit Kumar Direct admission in bba 2021-07-24 09:03
Ngoc Dickson Card Verification 2021-09-04 06:54
Victoria great 2022-03-16 07:49
martinek Buy Tadalista 20 Mg | Excellent ED pills | 20% OFF | USA | Genericday 2022-04-21 10:39
bodhizazenzs anette otoole 2022-10-13 13:14
Lalman1 Lalman1 2022-11-28 15:59
Lalman1 Lalman1 2022-11-28 16:00
hemant852 hemant852 2022-11-30 12:57
Shark852 Shark852 2022-12-10 11:35
judy Atoner 2022-12-27 04:16
James Hart     RE: Atoner 2023-03-06 07:25
GianaDorwart Dewapoker - Waktu Terbaik Bermain Slot Online 2023-03-19 17:43
Ana Jones MonkeyType 2023-03-20 12:16
Wordle Bot Conclusion of Wordle Bot 2023-03-24 09:09
James Hart     RE: Conclusion of Wordle Bot 2023-03-29 12:56
Ana Jones Monkey Type 2023-04-04 13:48
Robux to USD Robux to USD 2023-04-15 09:43
Spacebar098 What is Spacebar Counter? 2023-05-22 14:11
Time4ev: The Best Electric Scooter Supplier in Jaipur for Sustainable Mobility Best Electric Bicycle Dealer Supplier in Jaipur 2023-06-07 09:32
Nelly cuphead 2023-08-25 10:26
Nerdle Nerdle 2023-08-29 18:29
Nerdle Nerdle 2023-08-30 08:05
Nerdle Nerdle 2023-08-30 08:06
Nerdle Nerdle 2023-08-31 17:15
Ted Play a game 2023-09-05 06:23
Monkey type monkeytype 2023-09-22 08:40
Nerdle Game Today Nerdle 2023-10-12 10:46
Jenjira Jandee Bet on PGSLOT, The Wheel of Wealth 2023-11-21 20:42
Nanisa Dino game online for free 2023-11-27 05:39
Fnaf World thank you 2023-12-16 05:20
Nanasi12 Dino game 2024-04-09 06:21
Phoebe799 Studying and solving problems in games 2024-04-11 16:37
Nanasi12 Dino game 2024-05-22 04:15
clara167 Good 2024-05-31 09:50
celebsagewiki Thank you 2024-06-14 13:15


Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov