Skip to content
/ luhn Public

Generating and validating Luhn numbers in GO

License

Notifications You must be signed in to change notification settings

kolkov/luhn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An implementation of Luhn check-digit mod10 algorithm

Go Report Card Coverage Status Build Status

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

Compatible with the ozzo-validation package.

Usage

import "github.com/kolkov/luhn"

err := luhn.Validate("00123014764700968325")

signed := luhn.Generate("1")

test on your own by running make benchmark

Resources

About

Generating and validating Luhn numbers in GO

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages