close
The Wayback Machine - https://web.archive.org/web/20210102053409/https://github.com/jancajthaml-go/luhn
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

README.md

luhn check-digit mod10 algorithm

Go Report Card

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

import "github.com/jancajthaml-go/luhn"

ok := luhn.Validate("00123014764700968325")

digit, error := luhn.Digit("x")

checksum := luhn.Generate("1")

Performance

BenchmarkLuhnSmall          200000000  13.9 ns/op  0 B/op  0 allocs/op
BenchmarkLuhnLarge          50000000   31.8 ns/op  0 B/op  0 allocs/op
BenchmarkLuhnSmallParallel  300000000  4.06 ns/op  0 B/op  0 allocs/op
BenchmarkLuhnLargeParallel  100000000  15.0 ns/op  0 B/op  0 allocs/op

verify your performance by running make benchmark

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.