damm

package module
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: BSD-2-Clause Imports: 2 Imported by: 0

README

Package damm

The Go language package damm computes a check digit for a string of decimal digits. It uses an algorithm proposed by H. Michael Damm in 2004.

Examples

The function CheckDigit computes and returns it as string.

c, err := CheckDigit("12345678901")

The argument must contain only decimal digits. Otherwise an error is reported.

The function Validate verifies digits with the check digit appended.

ok := Validate("123456789018")

The function returns true if the argument contains only decimal digits and the appended check digit is correct.

Algorithm

More information about the algorithm can be found in Wikipedia.

http://en.wikipedia.org/wiki/Damm_algorithm

Documentation

Overview

Package damm supports the computation of a decimal checksum. It uses a method proposed by H. Michael Damm in 2004. The checksum doesn't change for leading zeroes.

The function CheckDigit computes the check sum as string:

c, err := CheckDigit("12345678901")

The function Validate checks whether the appended check digit is correct.

ok := Validate("123456789018")

Information about the algorithm is available on Wikipedia.

http://en.wikipedia.org/wiki/Damm_algorithm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDigit

func CheckDigit(digits string) (c string, err error)

CheckDigit computes the check digit and returns it as string. The function argument must only contain decimal digits.

func Validate

func Validate(digits string) bool

Validate checks a number with the check digit appended. The function returns true only if the argument contains only decimal digits and the appended check digit is correct.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL