I have developed my own cc (Credit Card Numbers) validator and generater in last week.
Luhn Algorithm
Most of the bank in world are using Luhn algorithm to validate their cc numbers are valid or not.
How Luhn algorithm work?
In my example I will use a validated cc to approve the algorithm that is really work or not in real world.
Card Number => 5300 7219 7517 4530
First we need to count the position of digits.
But we must count it from 0,1,2,3,etc.
And collect all odd numbers and calculate the total sum of odd numbers.
Sum of odd numbers = 3+0+2+9+5+7+5+0 = 31
Second , multiply the digits that are at even position with 2. If the double result is greater than 9 sum the two digit of multipled result.
Example
7×2 =14 => 1+4=7
And add them together.
I my case,the total sum of my even is 31.
Total sum of odd numbers = 29
Total sum of even number = 31
--------------------------------------------------
Total sum of all digits = 60
Divide the 60 with 10 and if its modulus is p it is valide and if it isn't.
Luhn and Panify NPM packages
I decided to create my own cc validator.So, I created Luhn and Panify node packages.
You can use it to validate your credit card numbers or clients credit card number in real world.
How to use them?
I use Luhn as dependency and it is integrated in Panify node package.
Requirements
Android or Linux or Mac OS or Window
Node.JS and NPM package manager
You can also use Yarn or PNPM package manager.
Installation
npm install -g panify
panify --help # for help information
panify --validate 4895042852684341
You can validate credit card number with --validate
flag.
You can generate random validated cc numbers .
pnaify -g 489504 # 489504 is the bin number of from validated credit card, you must support it if you don't know google it.
The return value of generated numbers are Array of objects.
[
{
card_number: 4895042852684341,
month: 2,
year: 2025
},
...
]
If you are JavaScript developer check my GitHub repos for more APIs and information.
Validator
https://github.com/amm834/luhn
Generator
If you are using Android phone check here.
https://amm834.github.io/Development-Environment-Setup-For-Android/
Contributing
If you are interested this project contribute it.
Roadmap
- Create a website that can generate validated credit card numbers deoend on his/her bin for end users
You can use my the credit cards for Google play store free trials and others.
It will work at Only Fans website 🤪.
Top comments (0)