Skip to main content

Luhn Account Number Validator

Project description

The Luhn Algorithm Validator

Tests 14-16 Digit Account Numbers for

Luhn Algorithm Compliance

This module, written in python3, takes a 14, 15, or 16 digit account number
(for example a credit/debit card number) and applies the Luhn Algorithm to
the provided data. If the data passes the test the system returns ‘True’,
else the system returns ‘False’.
An account number must be provided as a simple all-digits string without any
type of separators, including spaces, or the function will return ‘False’.
False values are also returned if the string contains any alpha characters,
punctuation marks or non-digit characters of any kind.

Using the Luhn Algorithm Validator

$ pip3 install Luhn_Algorithm_Validator

from luhn import aLuhn

>>> cardNumber = '2222222222222224'
>>> trueOrFalse = aLuhn.doLuhn(cardNumber)
>>> trueOrFalse
True

>>> cardNumber = '2222222222222222'
>>> trueOrFalse = aLuhn.doLuhn(cardNumber)
>>> trueOrFalse
False

Project details


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