Skip to main content
Check Digit Calculator
Core

Luhn Mod N Calculator

Calculate Luhn Mod N check characters for custom alphabets. See how character values and the chosen base determine the result.

Last updated:

Core Algorithms & Modulus

Extend Luhn to custom character sets.

Length: 9 chars
Calculated Check Character / Checksum
--Ready
Complete Validated Sequence:
--
Arithmetic Steps & Mathematical Specification

Initialising algorithm engine for Luhn Mod N Calculator...

How Luhn Mod N Calculator Works?

The Luhn Mod N Calculator works by mapping each character to a code point, doubling every second code point from the right, folding each result back into base N, and choosing the character that makes the total divisible by N. The default alphabet holds 36 characters (0–9 and A–Z), so N = 36.

  1. 1Choose the alphabet and record its size N (10 for digits, 16 for hexadecimal, 36 for 0–9A–Z).
  2. 2Convert every character to its code point: the index of the character inside the alphabet.
  3. 3Multiply the rightmost code point by 2, the next by 1, and keep alternating 2, 1 moving left.
  4. 4Fold each product into base N by adding its quotient and remainder after division by N.
  5. 5Sum the folded values and compute the check code point as (N − (sum mod N)) mod N.
  6. 6Convert the check code point back to its character and append it.

Luhn Mod N Calculator Formula

The Luhn Mod N formula is Check = alphabet[(N − (S mod N)) mod N], where S is the sum of folded, alternately doubled code points.

addendᵢ = fᵢ × cpᵢ,  fᵢ ∈ {2, 1} alternating from the right (starting with 2)
foldedᵢ = ⌊addendᵢ / N⌋ + (addendᵢ mod N)
Check code point = (N − (Σ foldedᵢ mod N)) mod N
  • N is the alphabet size (36 for 0–9A–Z).
  • cpᵢ is the code point of character i.
  • fᵢ is the factor 2 or 1.
  • foldedᵢ keeps every addend inside the base-N digit range.
Worked example: ABC123XYZ with N = 36
Z → 35 × 2 = 70 → 1 + 34 = 35
Y → 34 × 1 = 34 → 0 + 34 = 34
X → 33 × 2 = 66 → 1 + 30 = 31
3 → 3 × 1 = 3 → 0 + 3 = 3
2 → 2 × 2 = 4 → 0 + 4 = 4
1 → 1 × 1 = 1 → 0 + 1 = 1
C → 12 × 2 = 24 → 0 + 24 = 24
B → 11 × 1 = 11 → 0 + 11 = 11
A → 10 × 2 = 20 → 0 + 20 = 20
Sum S = 163
Check code point = (36 − (163 mod 36)) mod 36 = 17
Check character = H
Complete code = ABC123XYZH

Luhn Mod N Calculator Conversion Table

The Luhn Mod N conversion table lists character-to-code-point values for the 36-character alphabet next to sample payloads and their check characters.

CharactersCode pointsSample payloadCheck characterComplete code
0–90–9ABC123XYZHABC123XYZH
A–F10–15A1B2C3RA1B2C3R
G–L16–21HELLOJHELLOJ
M–R22–27MOD36YMOD36Y
S–X28–33SKU2026QSKU2026Q
Y–Z34–35ZZ99BZZ99B

Results use the 0–9A–Z alphabet with N = 36. A different alphabet order produces different check characters.

What is Luhn Mod N Calculator?

A Luhn Mod N Calculator is a tool that applies the Luhn algorithm to any alphabet of N characters instead of digits only. The Luhn mod N algorithm keeps the same doubling pattern as the classic Luhn method and replaces base 10 with base N.

Luhn mod N protects alphanumeric codes such as voucher codes, licence keys, and stock-keeping unit (SKU) numbers. N must be an even number for the folding step to keep full single-character error detection.

The classic Luhn Mod 10 algorithm is the special case N = 10 with the alphabet 0–9.

What are the uses of Luhn Mod N Calculator?

There are 4 main uses of the Luhn Mod N Calculator, including voucher codes, licence keys, and hexadecimal identifiers.

  • Voucher and gift codes: Retailers append a check character to alphanumeric voucher codes to reject typos at checkout.
  • Software licence keys: Developers add a Luhn mod N character to licence keys so the installer rejects mistyped keys offline.
  • Hexadecimal identifiers: Engineers apply N = 16 to hex device serials and memory tags.
  • Custom SKU schemes: Warehouses protect alphanumeric SKUs that a plain Mod 10 digit cannot cover.