Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
us.fatehi:creditcardnumber
Advanced tools
Credit Card Number is a library that can provide details of a bank issued credit card number. All classes are immutable and thread-safe. The standard `toString()` function formats data in a readable form.
Credit Card Number is a Java library that can provide details of a bank issued credit card number.
(Also see Magnetic Track Parser.)
The goal of this project is to use publicly and freely available documentation to create a reliable Java library to provide information about credit card numbers.
Some resources consulted are:
toString()
function formats data in a readable formYou can download the jar on the Maven Central Repository. The download page has instructions on how to use the library in your Maven or Gradle build.
To get bank card information, use code like:
AccountNumber pan = AccountNumbers.completeAccountNumber("5266-0922-0141-6174");
ExpirationDate expiration = new ExpirationDate(2015, 4);
Name name = new Name("Sualeh", "Fatehi");
ServiceCode serviceCode = new ServiceCode("225");
BankCard card = new BankCard(pan, expiration, name, serviceCode);
System.out.println(card);
and you will get this output:
Bank Card Information:
Raw Account Number: 5266-0922-0141-6174
Primary Account Number: 5266092201416174
Major Industry Identifier: 5 - Banking and financial
Issuer Identification Number: 52660922
Card Brand: MasterCard
Last Four Digits: 6174
Passes Luhn Check? Yes
Is Primary Account Number Valid? Yes
Expiration Date: 2015-04
Is Expired? Yes
Name: Sualeh Fatehi
Service Code:
2 - Interchange: International interchange. Technology: Integrated circuit card.
2 - Authorization Processing: By issuer.
5 - Allowed Services: Goods and services only. PIN Requirements: PIN required.
If you need the account number information, but want to be secure by not storing the actual primary account number in memory, you can use code like:
AccountNumber pan = AccountNumbers.completeAccountNumber("5266-0922-0141-6174");
pan.dispose();
System.out.println(pan.getAccountNumber());
and you will get this output:
null
The account number is no longer retained in memory. Even though the memory has been cleared of the account number, you may want to allow the original reference to be garbage collected by doing this:
// (Call dispose() first)
AccountNumber securePan = pan.toSecureAccountNumber();
If you need the account number information, but want to encrypt it using a cryptographic algorithm such as AES, you can use code like:
AccountNumber sealedPan = AccountNumbers.sealedAccountNumber("5266-0922-0141-6174", cipher);
System.out.println(sealedPan.getAccountNumber());
and you will get this output:
null
The account number can be decrypted by doing this:
AccountNumber pan = AccountNumbers.completeAccountNumber(sealedPan, key);
System.out.println(pan.getAccountNumber());
The cipher and key are from javax.crypto and java.security.
You can use code like:
AccountNumber pan = AccountNumbers.completeAccountNumber("५२६६ ०९२२ ०१४१ ६१७४");
System.out.println(pan.getAccountNumber());
and you will get this output:
5266092201416174
The Credit Card Number library allows look-ahead typing and identifies the card brand by at least the first four digits of the card number.
You can use code like:
CardBrand cardBrand = CardBrand.from("5366");
System.out.println(cardBrand);
and you will get this output:
MasterCard
FAQs
Credit Card Number is a library that can provide details of a bank issued credit card number. All classes are immutable and thread-safe. The standard `toString()` function formats data in a readable form.
We found that us.fatehi:creditcardnumber demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.