Number validator and generator based on luhn's formula
Project description
luhn-formula
Another Python ID validator and check digit generator package based on Luhn's formula :wink:. Luhn Formula was designed to protect against accidental input errors.
Usage
install
git clone git@github.com:code-127/luhn-formula.git
Example
>>> from luhnformula import luhnformula as lf
>>> lf.getcheckdigit("12345")
'5'
>>> lf.addcheckdigit("12345")
'123455'
>>> lf.isvalid("123455")
True
Function
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
luhn-formula-1.0.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for luhn_formula-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 130e2941e65e8d48d8fc5f698c28c303a89b2d84639d5d8fe83af352ea99b313 |
|
MD5 | 9b32abaf956c238905b40f011158859c |
|
BLAKE2b-256 | 34e79f604df4722e07ffbdfafbd5ea2b61c87f61e13decd1c810cf70f89414fe |