luhn v0.3.3 Luhn
Functions for validating Credit Card numbers using Luhn checksums.
Credit card numbers may be of arbitrary length and in arbitrary base.
Link to this section Summary
Functions
Evaluates a given credit card number for its validity, with an optionally provided base.
Link to this section Functions
Link to this function
checksum(number, base \\ 10)
Link to this function
double(list, base, acc)
Link to this function
valid?(number, base \\ 10)
Evaluates a given credit card number for its validity, with an optionally provided base.
Examples
# Accepts a string
iex(1)> Luhn.valid?("378282246310005")
true
# Or an integer
iex(2)> Luhn.valid?(378282246310005)
true
# Works with Hexadecimal as well
iex(3)> Luhn.valid?(0x1580BB2EA8875, 16)
true