/luhn

luhn check-digit validator and generator

Primary LanguageJavaScriptThe UnlicenseUnlicense

Performant implementation of Luhn check-digit mod10 algorithm

Algorithm will detect any single-digit error, as well as almost all transpositions of adjacent digits. It will not, however, detect transposition of the two-digit sequence 09 to 90 (or vice versa).

It is not intended to be a cryptographically secure hash function. It is mostly used for pre-flight credit card number validation as specified in ISO/IEC 7812-1:2015

Usage

const luhn = requite("luhn")

let ok = luhn.Validate("00123014764700968325")

let digit = luhn.Digit("x")

let signed = luhn.Generate("1")

test on your own by running make benchmark

Resources