Luhn Algorithm
Validate a variety of numbers such as credit cards and national identification numbers with the Luhn alogrithm published in 1960 by Hans Peter Luhn.
The original v0.3.3 by Takayuki Matsubara only validated numbers and is available at {:luhn, "~> 0.3.3"}.
This fork is available at {:luhn60, "~> 1.3"} and has these enhancements:
- ☑ CI for latest Elixir
- ☑ Property tests
- ☑ Compute check digit
- ☑ Append check digit
- ☑ Octal support
- ☐ Hexadecimal support
Installation
This fork:
{:luhn60, "~> 1.3"}Original:
{:luhn, "~> 0.3"}How to use
# validate number
Luhn.valid? "378282246310005"
# => true
# Integer type number
Luhn.valid? 378282246310005
# => true
# Compute check digit
Luhn.compute_check_digit("37828224631000")
# => 5Benchmarking
$ MIX_ENV=bench mix deps.get
$ MIX_ENV=bench mix compile
$ mix benchAuthor
Takayuki Matsubara (@ma2ge on twitter)
LICENSE
MIT