{"id":19039221,"url":"https://github.com/sualeh/creditcardnumber","last_synced_at":"2025-10-27T06:01:57.655Z","repository":{"id":20753874,"uuid":"24038391","full_name":"sualeh/creditcardnumber","owner":"sualeh","description":"Java library that can provide details of a bank issued credit card number","archived":false,"fork":false,"pushed_at":"2025-03-01T16:22:48.000Z","size":1103,"stargazers_count":71,"open_issues_count":2,"forks_count":31,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-30T02:07:39.395Z","etag":null,"topics":["android","credit-card","java-library","payment-processing","payments"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"WebAssembly/design","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sualeh.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sualeh","custom":"https://www.paypal.me/sualeh"}},"created_at":"2014-09-15T01:28:37.000Z","updated_at":"2025-03-09T17:35:34.000Z","dependencies_parsed_at":"2023-12-01T20:23:04.950Z","dependency_job_id":"6ddf38b1-dd62-458d-83ab-3d9a54d60604","html_url":"https://github.com/sualeh/creditcardnumber","commit_stats":null,"previous_names":["sualeh/credit_card_number"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sualeh%2Fcreditcardnumber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sualeh%2Fcreditcardnumber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sualeh%2Fcreditcardnumber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sualeh%2Fcreditcardnumber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sualeh","download_url":"https://codeload.github.com/sualeh/creditcardnumber/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","credit-card","java-library","payment-processing","payments"],"created_at":"2024-11-08T22:12:13.407Z","updated_at":"2025-10-27T06:01:57.570Z","avatar_url":"https://github.com/sualeh.png","language":"Java","funding_links":["https://github.com/sponsors/sualeh","https://www.paypal.me/sualeh","https://www.paypal.com/us/smarthelp/article/where-can-i-find-test-credit-card-numbers-ts2157"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD040 MD041 MD004 MD012 --\u003e\r\n[![Quick Build](https://github.com/sualeh/creditcardnumber/actions/workflows/quick_build.yml/badge.svg)](https://github.com/sualeh/creditcardnumber/actions/workflows/quick_build.yml)\r\n[![Code Climate](https://codeclimate.com/github/sualeh/creditcardnumber.png)](https://codeclimate.com/github/sualeh/creditcardnumber)\r\n[![Code Coverage](https://img.shields.io/codeclimate/coverage/sualeh/creditcardnumber)](https://codeclimate.com/github/sualeh/creditcardnumber)\r\n[![The Central Repository](https://img.shields.io/maven-central/v/us.fatehi/creditcardnumber.svg)](https://search.maven.org/search?q=g:us.fatehi%20creditcardnumber*)\r\n\r\n\r\n\u003e **:star: Star it :arrow_heading_up: if you love it!**\r\n\r\n# Credit Card Number\r\n\r\n*Credit Card Number* is a Java library that can provide details of a bank issued\r\ncredit card number.\r\n\r\n(Also see [Magnetic Track Parser](https://github.com/sualeh/magnetictrackparser).)\r\n\r\n\u003e **The goal of this project is to use publicly and freely available documentation\r\nto create a reliable Java library to provide information about credit card numbers.**\r\n\r\n\r\n## Resources\r\n\r\nSome resources consulted are:\r\n\r\n- [Payment card number](https://en.wikipedia.org/wiki/Payment_card_number)\r\n- [How do you detect Credit card type based on number?](http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number)\r\n- [Finding or Verifying Credit Card Numbers](http://www.regular-expressions.info/creditcard.html)\r\n- [Major Industry Identifier](https://en.wikipedia.org/wiki/ISO/IEC_7812#Major_industry_identifier)\r\n- [Luhn Algorithm](http://en.wikipedia.org/wiki/Luhn_algorithm)\r\n- [Where can I find test credit card numbers?](https://www.paypal.com/us/smarthelp/article/where-can-i-find-test-credit-card-numbers-ts2157)\r\n\r\n\r\n## Design Principles\r\n\r\n- All classes are immutable and thread-safe\r\n- Secure data follows standards in the\r\n[Java Cryptography Architecture (JCA) Reference Guide](https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html#PBEEx)\r\n- The standard `toString()` function formats data in a readable form\r\n- Internationalization of card numbers is supported\r\n- Validity is enforced by JUnit 5 tests\r\n- Java 8 or newer is required\r\n- Android friendly\r\n\r\n\r\n## Download and Use in Projects\r\n\r\nYou can [download the jar on the Maven Central Repository](https://search.maven.org/artifact/us.fatehi/creditcardnumber).\r\nThe [download page](https://search.maven.org/artifact/us.fatehi/creditcardnumber) has instructions on how to use the library in your Maven or Gradle build.\r\n\r\n\r\n## Examples\r\n\r\n### How to Get Bank Card Information\r\n\r\nTo get bank card information, use code like:\r\n\r\n```java\r\nAccountNumber pan = AccountNumbers.completeAccountNumber(\"5266-0922-0141-6174\");\r\nExpirationDate expiration = new ExpirationDate(2015, 4);\r\nName name = new Name(\"Sualeh\", \"Fatehi\");\r\nServiceCode serviceCode = new ServiceCode(\"225\");\r\nBankCard card = new BankCard(pan, expiration, name, serviceCode);\r\nSystem.out.println(card);\r\n```\r\n\r\nand you will get this output:\r\n\r\n```\r\nBank Card Information:\r\n  Raw Account Number: 5266-0922-0141-6174\r\n  Primary Account Number: 5266092201416174\r\n    Major Industry Identifier: 5 - Banking and financial\r\n    Issuer Identification Number: 52660922\r\n    Card Brand: MasterCard\r\n    Last Four Digits: 6174\r\n    Passes Luhn Check? Yes\r\n    Is Primary Account Number Valid? Yes\r\n  Name: Sualeh Fatehi\r\n  Expiration Date: 2015-04\r\n    Is Expired? Yes\r\n  Service Code:\r\n    2 - Interchange: International interchange. Technology: Integrated circuit card.\r\n    2 - Authorization Processing: By issuer.\r\n    5 - Allowed Services: Goods and services only. PIN Requirements: PIN required.\r\n```\r\n\r\n\r\n### How to Secure the Credit Card Number\r\n\r\nIf 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:\r\n\r\n```java\r\nAccountNumber pan = AccountNumbers.completeAccountNumber(\"5266-0922-0141-6174\");\r\npan.dispose();\r\nSystem.out.println(pan.getAccountNumber());\r\n```\r\n\r\nand you will get this output:\r\n\r\n```\r\nnull\r\n\r\n```\r\n\r\nThe account number is no longer retained in memory. Even though the memory has been cleared of\r\nthe account number, you may want to allow the original reference to be garbage collected by\r\ndoing this:\r\n\r\n```java\r\n// (Call dispose() first)\r\nAccountNumber securePan = pan.toSecureAccountNumber();\r\n```\r\n\r\n\r\n### How to Encrypt the Credit Card Number\r\n\r\nIf you need the account number information, but want to encrypt it using a cryptographic algorithm such as AES, you can use code like:\r\n\r\n```java\r\nAccountNumber sealedPan = AccountNumbers.sealedAccountNumber(\"5266-0922-0141-6174\", cipher);\r\nSystem.out.println(sealedPan.getAccountNumber());\r\n```\r\n\r\nand you will get this output:\r\n\r\n```\r\nnull\r\n\r\n```\r\n\r\nThe account number can be decrypted by doing this:\r\n\r\n```java\r\nAccountNumber pan = AccountNumbers.completeAccountNumber(sealedPan, key);\r\nSystem.out.println(pan.getAccountNumber());\r\n```\r\n\r\nThe cipher and key are from [javax.crypto and java.security](https://docs.oracle.com/en/java/javase/17/security/java-security-overview1.html).\r\n\r\n\r\n### Internationalization is Supported\r\n\r\nYou can use code like:\r\n\r\n```java\r\nAccountNumber pan = AccountNumbers.completeAccountNumber(\"५२६६ ०९२२ ०१४१ ६१७४\");\r\nSystem.out.println(pan.getAccountNumber());\r\n```\r\n\r\nand you will get this output:\r\n\r\n```\r\n5266092201416174\r\n```\r\n\r\n\r\n### Look-ahead Typing\r\n\r\nThe Credit Card Number library allows look-ahead typing and identifies the\r\ncard brand by at least the first four digits of the card number.\r\n\r\nYou can use code like:\r\n\r\n```java\r\nCardBrand cardBrand = CardBrand.from(\"5366\");\r\nSystem.out.println(cardBrand);\r\n```\r\n\r\nand you will get this output:\r\n\r\n```\r\nMasterCard\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsualeh%2Fcreditcardnumber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsualeh%2Fcreditcardnumber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsualeh%2Fcreditcardnumber/lists"}