-2

At the moment I am working on a credit card validation program with the Luhn algorithm. So far it is working, but the next thing is to tell which bank issued the card. Of course not all of them, just a few.

The question: What is the proper way to store the possible six digit numbers under one issuer?

One bank can have 5-10-20 beginning sequence of digits, but I can't figure out the proper data storing method.

Jan Aagaard Meier
  • 28,078
  • 8
  • 95
  • 66
Paxsentry
  • 193
  • 2
  • 14
  • 1
    why don't u try the **List** collection – Deepak Sharma Dec 12 '14 at 06:50
  • If there's no database backend, then perhaps consider sqlite as your data storage solution. You'd also look at a one-to-many table structure to store the data per bank with multiple sequences – user3036342 Dec 12 '14 at 07:05

1 Answers1

-1

You can use regex to test if the entered string matches credit card formats and then if it matches a specific bank identification. To answer the question, reggae can send the match found to a specific method. This one could analyse the match and check if the digits are correct now that you know the bank issuer. But, I strongly recommend thinking twice before store cards information. You must use encryption, even in your datastore, using a strong algorithm and store the encryption key elsewhere !!!

Some Explanation found on the web:

  • Visa: ^4[0-9]{12}(?:[0-9]{3})?$ All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
  • MasterCard: ^5[1-5][0-9]{14}$ All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
  • American Express: ^3[47][0-9]{13}$ American Express card numbers start with 34 or 37 and have 15 digits.
  • Diners Club: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$ Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. There are Diners Club cards that begin with 5 and have 16 digits. These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard.
  • Discover: ^6(?:011|5[0-9]{2})[0-9]{12}$ Discover card numbers begin with 6011 or 65. All have 16 digits.
  • JCB: ^(?:2131|1800|35\d{3})\d{11}$ JCB cards beginning with 2131 or 1800 have 15 digits. JCB cards beginning with 35 have 16 digits.

it then renders:

?:4[0-9]{12}(?:[0-9]{3})?          # Visa
|  5[1-5][0-9]{14}                  # MasterCard
|  3[47][0-9]{13}                   # American Express
|  3(?:0[0-5]|[68][0-9])[0-9]{11}   # Diners Club
|  6(?:011|5[0-9]{2})[0-9]{12}      # Discover
|  (?:2131|1800|35\d{3})\d{11}      # JCB
)$

Credits:

FrenchW
  • 28
  • 6
  • Sorry guys, newbie problem. But, it answers the question if I cut and paste the link content? I prefer leaving credits to the page – FrenchW Dec 12 '14 at 07:12
  • I didn't downvote but I also don't think this answers the actual question being asked, these appear to be for card types and not for bank issuers. (As a side note, I also find it amusing that "reggae can send the match") – Sayse Dec 12 '14 at 07:30
  • Thanks FrenchW, but this is not the solution I am looking for. Probably an example will help to explain better my question: The RBS Visa cards are beginning with these digits: 446279 475116 475117 475118 475126 476225 484474 I am looking for a data structure where these numbers can be stored under eg. RBS-Visa name. – Paxsentry Dec 12 '14 at 18:10