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 & Hexadecimal support
This fork:
{:luhn60, "~> 1.3"}
Original:
{:luhn, "~> 0.3"}
# validate number
Luhn.valid? "378282246310005"
# => true
# Integer type number
Luhn.valid? 378282246310005
# => true
# Compute check digit
Luhn.compute_check_digit("37828224631000")
# => 5
# Append check digit
Luhn.append_check_digit("37828224631000")
"378282246310005"
$ MIX_ENV=bench mix deps.get
$ MIX_ENV=bench mix compile
$ mix bench
Takayuki Matsubara (@ma2ge on twitter)
MIT