Extend Luhn to custom character sets.
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.
- 1Choose the alphabet and record its size N (10 for digits, 16 for hexadecimal, 36 for 0–9A–Z).
- 2Convert every character to its code point: the index of the character inside the alphabet.
- 3Multiply the rightmost code point by 2, the next by 1, and keep alternating 2, 1 moving left.
- 4Fold each product into base N by adding its quotient and remainder after division by N.
- 5Sum the folded values and compute the check code point as (N − (sum mod N)) mod N.
- 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 NNis 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.
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.
| Characters | Code points | Sample payload | Check character | Complete code |
|---|---|---|---|---|
| 0–9 | 0–9 | ABC123XYZ | H | ABC123XYZH |
| A–F | 10–15 | A1B2C3 | R | A1B2C3R |
| G–L | 16–21 | HELLO | J | HELLOJ |
| M–R | 22–27 | MOD36 | Y | MOD36Y |
| S–X | 28–33 | SKU2026 | Q | SKU2026Q |
| Y–Z | 34–35 | ZZ99 | B | ZZ99B |
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.