All Tools
Tools/Luhn Algorithm
✅
ValidationAvailable
Luhn Algorithm
Validate any numeric string with the Luhn algorithm. Shows a step-by-step digit-level calculation trace — useful for understanding why a card number is valid or not.
Use test data only. All calculations run locally in your browser — PayProbe never sees, transmits, or stores your PAN, CVV, keys, PINs, or cryptographic inputs. How we handle data →
Luhn check digit calculator
</> Code Implementation
# Luhn Algorithm — validate and generate check digit
# No external dependencies required
def luhn_validate(number: str) -> bool:
digits = [int(c) for c in number if c.isdigit()]
total = 0
for i, d in enumerate(reversed(digits)):
if i % 2 == 1:
d *= 2
if d > 9:
d -= 9
total += d
return total % 10 == 0
def luhn_check_digit(partial: str) -> int:
for check in range(10):
if luhn_validate(partial + str(check)):
return check
return -1
# Example
pan = "411111111111111"
check = luhn_check_digit(pan)
full = pan + str(check)
print(f"Check digit : {check}")
print(f"Full PAN : {full}")
print(f"Valid : {luhn_validate(full)}")
# Check digit : 1
# Full PAN : 4111111111111111
# Valid : True