Skip to content

XUJiahua/go-luhn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Generating and validating Luhn numbers in GO

import (
  "github.com/joeljunstrom/go-luhn"
  "fmt"
)

// Checking if a string is a valid luhn
luhn.Valid("1234") //= false
luhn.Valid("562246784655") //= true

// Generating a valid luhn string of a specified size
randomLuhn := luhn.Generate(12)
fmt.Println(randomLuhn) //= "802252051072"

// Generating a valid luhn string of a specified size
// with a given prefix
randomLuhnWithPrefix := luhn.GenerateWithPrefix(10, "12345")
fmt.Println(randomLuhnWithPrefix) //= "1234533220"

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%