# Luhn
[](https://hex.pm/packages/luhn)
[](https://hex.pm/packages/luhn)
[](https://github.com/epinault/luhn_ex/actions?query=workflow%3ACI)
Luhn algorithm implementation in Elixir for validating credit card numbers,
IMEI numbers, and other identification numbers that use the Luhn checksum.
Supports arbitrary bases (decimal, hexadecimal, etc.).
## Installation
Add `luhn` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:luhn, "~> 0.3"}
]
end
```
## Usage
```elixir
# Validate a credit card number (string)
Luhn.valid?("378282246310005")
# => true
# Also works with integers
Luhn.valid?(4111111111111111)
# => true
# Hexadecimal support
Luhn.valid?("abc1239", 16)
# => true
# Get the checksum value
Luhn.checksum("378282246310005")
# => 0
```
## Documentation
Full documentation is available on [HexDocs](https://hexdocs.pm/luhn).
## Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## License
MIT — see [LICENSE](LICENSE) for details.