luhn

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 2 Imported by: 0

README

An implementation of 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/kolkov/luhn"

result, _ := luhn.Validate("00123014764700968325")

signed := luhn.Generate("1")

test on your own by running make benchmark

Resources

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(source string) (string, error)

Generate return the number with check digit

func Validate

func Validate(code string) (bool, error)

Validate check number is valid or not based on Luhn algorithm

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL