luhn
Generate and verify Luhn check digits
What it is and what it does
Luhn is a minimal Python library that implements the Luhn algorithm, a checksum formula used to validate identification numbers like credit card numbers. It provides three functions: `verify()` to check whether a digit string has a valid Luhn check digit, `generate()` to compute the correct check digit for a given number, and `append()` to return the number with its check digit appended.
The package has no external dependencies and is straightforward to use. However, it has been abandoned since its single release on 2015-06-23, with no updates for many years. While the algorithm itself is simple and unlikely to change, the lack of maintenance means any compatibility issues with newer Python versions or edge cases would not be addressed by the maintainer.
Use it for:
- Validate credit card numbers or other financial identifiers that use Luhn checksums before processing.
- Generate correct check digits for test data or synthetic credit card numbers in development environments.
- Verify the integrity of digit sequences in payment systems or identity verification workflows.
- Append Luhn check digits to partial account numbers or identifiers in data generation pipelines.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates and verifies Luhn check digits for digit strings, commonly used to validate credit card numbers and similar identifiers.
Yes, but with caution. The package does exactly what it claims and has no known vulnerabilities. MIT licensing is unrestricted. However, it is abandoned and has not been updated since 2015-06-23—install only if you are confident the Luhn algorithm implementation is correct for your use case and you can tolerate no future maintenance. For production payment systems, consider whether a maintained alternative would be safer.
Install
luhn on PyPI
pip
pip install luhnuv
uv add luhnpoetry
poetry add luhnInstalling luhn
Before you install
High install friction: the package has been abandoned since its only release on 2015-06-23, with no updates in many years. The last repository commit was 2023-03-14, suggesting minimal maintenance. No runtime dependencies, so installation itself is straightforward, but the stagnation raises questions about whether bugs or compatibility issues would be addressed.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or redistribution in commercial or private projects.
Quickstart
pip install luhn
from luhn import verify, generate, append
verify('356938035643809') # True
generate('53461861341123') # 4
append('53461861341123') # '534618613411234'
Verify before relying
- Whether the package works correctly with modern Python versions, given no updates since 2015-06-23 and no specified Python support in metadata.
- Whether the Luhn algorithm implementation matches current standards or has any known edge cases not covered by the fact sheet.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 4,070 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 178,384/month — #10,195 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: luhn-0.2.0.tar.gz
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
paytmchecksumGenerates and verifies checksums for Paytm…
permissive · top 15,000 on PyPI
python-stdnumParses, validates, and reformats standard…
copyleft · top 5,000 on PyPI
vonage-network-number-verificationVerifies a mobile device's phone number by…
permissive · top 15,000 on PyPI
lexidGenerates lexically ordered numerical IDs that…
permissive · top 15,000 on PyPI
brazilnumValidates and formats Brazilian identification…
permissive · top 15,000 on PyPI
inventree-ipn-generatorAutomatically generates and assigns Internal…
permissive · top 15,000 on PyPI
crcCalculate, verify, and manage CRC checksums…
permissive · top 5,000 on PyPI
text2digitsConverts written-out number words in text to…
permissive · top 15,000 on PyPI
filehashCalculates and verifies file checksums and…
permissive · top 15,000 on PyPI
word2numberConverts written-out number words (like "twenty…
permissive · top 5,000 on PyPI