luhn-formula
Another python package of number validator and check digit generator based on Luhn's formula 😉. Luhn's formula was designed to protect against accidental input errors.
Usage
install
pip install luhn-formula
or
git clone git@github.com:code-127/luhn-formula-py.git
Example
>>> from luhnformula import luhnformula as lf
>>> lf.getcheckdigit("12345")
'5'
>>> lf.addcheckdigit("12345")
'123455'
>>> lf.isvalid("123455")
True
Function
checksum(number: str) -> int
Checksum vith the luhn formula
Args:
number : Number to calculate
return:
Result of luhn formula
isvalid(number: str) -> bool:
Validate number with the Luhn formula.
Args:
number: Number to validate.
Returns:
``True`` when the: number is valid, otherwise ``False``.
getcheckdigit(number: str) -> str:
Generate check digit with the Luhn formula for a number.
Args:
number: Number used to generate the check digit.
Return:
the check digit for a number.
Raise error:
ValueError : Invalid number.
addcheckdigit(number: str) -> str:
Generate and add check digit with the luhn formula for a number
Args:
number: Number used to generate the check digit.
Return:
the number with the check digit.
Raise error:
ValueError : Invalid number.
Metadata
Release files for luhn-formula 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| luhn_formula-1.0.6.tar.gz | 3.7 kB | Without provenance | Details for luhn_formula-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| luhn_formula-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for luhn_formula-1.0.6-py3-none-any.whl |
Total release size: 7.6 kB
Release files / luhn_formula-1.0.6.tar.gz
| Download URL | luhn_formula-1.0.6.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09d787fb73ea84939e52e887959f20ec4b342f84826640850bda7a823859d11f
|
|
BLAKE2b-256 checksum How to use checksums |
4cd4c0faa680030a8144e685aae093d033ef969114ea3bc0c2289afd788efaa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / luhn_formula-1.0.6-py3-none-any.whl
| Download URL | luhn_formula-1.0.6-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9381010f9cd89588352d54bcf81fa6e6f09b0b81870eec53bf7fc50785f01f49
|
|
BLAKE2b-256 checksum How to use checksums |
19a8046cab329fba0cef573564688e90021c7b62e71f80517097f31a2ee60677
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for luhn-formula 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.