- Notifications
You must be signed in to change notification settings - Fork12
CCNumGen is a Python 3.9+ class that uses the Luhn algorithm to generate theoretically valid credit card numbers with CVV and expiration dates.
License
wcDogg/python-cc-num-gen
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
CCNumGen is a Python 3.9 class that uses theLuhn Algorithm to generate theoretically valid credit card numbers with CVV and expiration dates.
- It can generate Amex, Discover, MC, Visa 13, and Visa 16 cards.
- It generates 3 or 4 digit CVV numbers, depending on the card type.
- It generates an expiration date that is 1 to 3 years from today.
- It prints each card to the console.
- It captures cards in a list of dictionaries.
Adapted from:https://stackoverflow.com/questions/59232327/python-how-to-always-generate-valid-luhn-numbers
These are theoretical cards meant for testing the pre-checks that happen on a payment screen before payment is submitted. This utility does not generate real-world card information. For example, real CSV numbers are generated using an algorithm tied to the card number and other data points - something this utility can't do.
Sometimes for testing you need card numbers with specific prefixes.CCNumGen is easy to extend.
- Name the new card type in the
CCNumGenclass ->card_typeslist. - Define the new card in the
CCclass ->CCDATAdictionary.
CCNumGen generates 5 types of cards. The second argument is the number of cards to generate.
amex = CCNumGen('amex', 2)discover = CCNumGen('discover', 2)mc = CCNumGen('mc', 2)visa13 = CCNumGen('visa13', 2)visa16 = CCNumGen('visa16', 2)Each card is printed to the console.
---------------------------Type: amexNumber: 372672737435387CVV: 8483Exp: 09-2025---------------------------Type: discoverNumber: 60019219645956610CVV: 892Exp: 05-2023---------------------------Type: mcNumber: 5169546719828815CVV: 678Exp: 03-2023---------------------------Type: visa13Number: 4929291332548CVV: 328Exp: 08-2025---------------------------Type: visa16Number: 4165317319538881CVV: 106Exp: 05-2024---------------------------Each card is stored in a list of dictionaries.
[ { 'cc_type': 'mc', 'cc_num': '5538992865196249', 'cc_cvv': '617', 'cc_exp': '09-2024' }, { 'cc_type': 'mc', 'cc_num': '5191748311982485', 'cc_cvv': '434', 'cc_exp': '11-2023' }]To access the list directly:
print(amex.card_list)print(discover.card_list)print(mc.card_list)print(visa13.card_list)print(visa16.card_list)To print the list to console:
amex.print_card_list()discover.print_card_list()mc.print_card_list()visa13.print_card_list()visa16.print_card_list()| Card | Length | Starts With | CVV Len | CVV Location |
|---|---|---|---|---|
| Visa 13 | 13 digits | 4xx | 3 | Back - left of sig |
| Visa 16 | 16 digits | 4xx | 3 | Back - left of sig |
| MasterCard | 16 digits | 51 or 55 | 3 | Back - left of sig |
| Amex | 15 digits | 34 or 37 | 4 | Front - above CC num |
| Discover | 16 digits | 6011 | 3 | Back - last 3, after acct num |
Other names:
- CSC - Card Security Code
- CID - Card Identification Number
- CVC2 - Card Verification Code
- CVV2 - Card Verification Value
What is it?
- An anti-fraud measure used by CC companies worldwide.
- A 3 or 4 digit number printed on the physical card - and not embossed.
- Used for Card Not Present (CNP) transactions.
- Different from the CVV1 that's encoded on track 2 of the magnetic strip - this is used for Card Present Transactions (CPT).
Generated with DES encryption using:
- Pair of DES keys (CVKs)
- Primary Account Number (PAN)
- 4-digit Expiration Date.
- 3-digit Service Code.
- Other data
Amex:
- Does have a 3 digit CID code on back of card.
- Uses the 4 digit CVV number on front of card for CNP transactions.
About
CCNumGen is a Python 3.9+ class that uses the Luhn algorithm to generate theoretically valid credit card numbers with CVV and expiration dates.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.