https://github.com/adamjdeacon/checkluhn
Checks if a number is valid per the luhn algorithm
https://github.com/adamjdeacon/checkluhn
credit-card creditcard-validator luhn luhn-algorithm r validation
Last synced: about 2 months ago
JSON representation
Checks if a number is valid per the luhn algorithm
- Host: GitHub
- URL: https://github.com/adamjdeacon/checkluhn
- Owner: adamjdeacon
- License: gpl-3.0
- Created: 2018-08-23T14:41:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-13T15:42:44.000Z (about 2 years ago)
- Last Synced: 2025-12-09T21:52:46.804Z (5 months ago)
- Topics: credit-card, creditcard-validator, luhn, luhn-algorithm, r, validation
- Language: R
- Size: 39.1 KB
- Stars: 5
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
# CheckLuhn
[](https://travis-ci.org/adamjdeacon/checkLuhn)
[](https://ci.appveyor.com/project/adamjdeacon/checkLuhn)
[](https://codecov.io/gh/adamjdeacon/checkLuhn?branch=master)
[](http://www.rdocumentation.org/packages/checkLuhn)
## Overview
checkLuhn is package to assist checking PANs (credit/debit card number) or any
other number that uses the Luhn algorithum to validte.
The algorithm is in the public domain and is in wide use today. It is specified
in ISO/IEC 7812-1. It is not intended to be a cryptographically secure hash
function; it was designed to protect against accidental errors, not malicious
attacks. Most credit cards and many government identification numbers use the
algorithm as a simple method of distinguishing valid numbers from mistyped or
otherwise incorrect numbers.
The `issuer` function will can return the Card Issuer/Scheme and if that scheme
is active or not
## Installation
``` r
# The easiest way to get checkLuhn:
install.packages("checkLuhn")
```
### Development version
To get a bug fix, or use a feature from the development version, you can
install dplyr from GitHub.
``` r
# install.packages("devtools")
devtools::install_github("adamjdeacon/checkLuhn")
```
## Usage
``` r
library(checkLuhn)
# Invalid number
input <- "4111 2234 2242 1234"
checkLuhn(input)
[1] FALSE
# Valid number
input <- "34000000 0000 009"
checkLuhn(input)
[1] TRUE
# Check for card type
input <- '378282246310005'
> issuer(input)
# A tibble: 1 x 2
issuer active
1 American Express Yes
```
## Getting help
If you encounter a clear bug, please file a minimal reproducible example
on [github](https://github.com/adamjdeacon/checkLuhn/issues).