Skip to main content

Fast Luhn algorithm

Project description

Luhn algorithm. Generate and validate strings of numbers. Rust realisation for speed-up python code.

Author:

Matt Stroganov

Version:

0.1.2

Installation

Install with pip:

$ pip install fast-luhn

Usage

Import package:

>>> import fast_luhn as fl

Validate

Check if string is valid by luhn algorithm. Return bool.

>>> fl.validate("471629309440")
False

Digit

Calculate next digit for string of numbers. Return int.

>>> fl.digit("47162930944")
7

Complete

Add luhn-check digit to string of numbers. Return string.

>>> fl.complete("2398560146")
'23985601469'

Generate

Generate luhn-valid string of numbers with length. Return string.

>>> fl.generate(50)
'58126333877729238938910323395262199130041545367401'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

fast_luhn-0.1.2-cp37-cp37m-manylinux1_x86_64.whl (590.3 kB view hashes)

Uploaded CPython 3.7m

fast_luhn-0.1.2-cp36-cp36m-manylinux1_x86_64.whl (443.6 kB view hashes)

Uploaded CPython 3.6m

fast_luhn-0.1.2-cp35-cp35m-manylinux1_x86_64.whl (296.9 kB view hashes)

Uploaded CPython 3.5m

fast_luhn-0.1.2-cp27-cp27mu-manylinux1_x86_64.whl (150.2 kB view hashes)

Uploaded CPython 2.7mu

fast_luhn-0.1.2-cp27-cp27m-manylinux1_x86_64.whl (150.2 kB view hashes)

Uploaded CPython 2.7m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page