Credit Card Number

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.

License

License

GroupId

GroupId

us.fatehi
ArtifactId

ArtifactId

credit_card_number
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Credit Card Number
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.
Project URL

Project URL

https://github.com/sualeh/credit_card_number
Project Organization

Project Organization

Sualeh Fatehi
Source Code Management

Source Code Management

https://github.com/sualeh/credit_card_number

Download credit_card_number

How to add to project

<!-- https://jarcasting.com/artifacts/us.fatehi/credit_card_number/ -->
<dependency>
    <groupId>us.fatehi</groupId>
    <artifactId>credit_card_number</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/us.fatehi/credit_card_number/
implementation 'us.fatehi:credit_card_number:3.0.0'
// https://jarcasting.com/artifacts/us.fatehi/credit_card_number/
implementation ("us.fatehi:credit_card_number:3.0.0")
'us.fatehi:credit_card_number:jar:3.0.0'
<dependency org="us.fatehi" name="credit_card_number" rev="3.0.0">
  <artifact name="credit_card_number" type="jar" />
</dependency>
@Grapes(
@Grab(group='us.fatehi', module='credit_card_number', version='3.0.0')
)
libraryDependencies += "us.fatehi" % "credit_card_number" % "3.0.0"
[us.fatehi/credit_card_number "3.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.12.0
org.apache.commons : commons-text jar 1.9

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.7.0
org.hamcrest : hamcrest jar 2.2

Project Modules

There are no modules declared in this project.

Quick Build The Central Repository

Credit Card Number

Credit Card Number is a Java library that can provide details of a bank issued credit card number.

Resources

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:

Design Principles

  • All classes are immutable and thread-safe
  • Secure data follows standards in the Java Cryptography Architecture (JCA) Reference Guide
  • The standard toString() function formats data in a readable form
  • Internationalization of card numbers is supported
  • Validity is enforced by JUnit 5 tests
  • Java 8 or newer is required

Download and Use in Projects

You 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.

Examples

How to Get Bank Card Information

To get bank card information, use code like:

AccountNumber pan = AccountNumbers.accountNumber("5266-0922-0141-6174");
ExpirationDate expiration = new ExpirationDate(2015, 4);
Name name = new Name("Sualeh", "Fatehi");
BankCard card = new BankCard(pan, expiration, name);
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: 526609
    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

How to Secure the Credit Card Number

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.accountNumber("5266-0922-0141-6174");
pan.dispose();
System.out.println(pan);

and you will get this output:

Account Number: 
  Major Industry Identifier: 5 - Banking and financial
  Issuer Identification Number: null
  Card Brand: MasterCard
  Passes Luhn Check? Yes
  Is Primary Account Number Valid? Yes

Internationalization is Supported

You can use code like:

AccountNumber pan = AccountNumbers.accountNumber("५२६६ ०९२२ ०१४१ ६१७४");
System.out.println(pan);

and you will get this output:

5266092201416174

Versions

Version
3.0.0
2.2.3
2.2.2
2.02.01
2.01.02
2.01.01
2.00.01
1.10.01
1.9
1.8
1.7
1.6
1.3
1.1
1.0