Documentation
¶
Overview ¶
Package verhoeff implements the Verhoeff algorithm for checksum calculation and validation. The Verhoeff algorithm is a checksum formula for error detection developed by Dutch mathematician J. Verhoeff. It can detect all single-digit errors and most transposition errors. For more information: https://en.wikipedia.org/wiki/Verhoeff_algorithm
Index ¶
- func AppendChecksum(input interface{}) (string, error)
- func AppendChecksumInt(n int) string
- func AppendChecksumInt64(n int64) string
- func AppendChecksumSlice(digits []int) (string, error)
- func AppendChecksumString(s string) (string, error)
- func ConvertToDigits(input interface{}) ([]int, error)
- func Generate(input interface{}) (int, error)
- func GenerateFromString(s string) (int, error)
- func GenerateInt(n int) int
- func GenerateInt64(n int64) int
- func GenerateSlice(digits []int) (int, error)
- func GenerateString(input interface{}) (string, error)
- func InvertArray(input interface{}) ([]int, error)
- func Validate(input interface{}) (bool, error)
- func ValidateAadhaar(aadhaarStr string) (bool, error)
- func ValidateInt(n int) bool
- func ValidateInt64(n int64) bool
- func ValidateSlice(digits []int) (bool, error)
- func ValidateString(s string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendChecksum ¶
AppendChecksum adds the calculated checksum digit to the input. Supported types: string, int, int64, []int This function is kept for backward compatibility but using the type-specific functions (AppendChecksumString, AppendChecksumInt, etc.) is recommended.
func AppendChecksumInt ¶
AppendChecksumInt adds the calculated checksum digit to an integer.
func AppendChecksumInt64 ¶
AppendChecksumInt64 adds the calculated checksum digit to an int64.
func AppendChecksumSlice ¶
AppendChecksumSlice adds the calculated checksum digit to a slice of digits.
func AppendChecksumString ¶
AppendChecksumString adds the calculated checksum digit to a string.
func ConvertToDigits ¶
ConvertToDigits converts various input types to a slice of digits. Supported types: string, int, int64, []int This function provides compatibility with the original API.
func Generate ¶
Generate calculates the Verhoeff checksum digit for various input types. Supported types: string, int, int64, []int This function is kept for backward compatibility but using the type-specific functions (GenerateFromString, GenerateInt, etc.) is recommended.
func GenerateFromString ¶
GenerateFromString calculates the Verhoeff checksum digit for a string of digits.
func GenerateInt ¶
GenerateInt calculates the Verhoeff checksum digit for an integer.
func GenerateInt64 ¶
GenerateInt64 calculates the Verhoeff checksum digit for an int64.
func GenerateSlice ¶
GenerateSlice calculates the Verhoeff checksum digit for a slice of digits.
func GenerateString ¶
GenerateString is an alias for Generate that returns a string. Deprecated: Use Generate instead.
func InvertArray ¶
InvertArray converts input to a slice of digits and reverses it. This function provides compatibility with the original API.
func Validate ¶
Validate checks if a number with its checksum digit is valid. Supported types: string, int, int64, []int This function is kept for backward compatibility but using the type-specific functions (ValidateString, ValidateInt, etc.) is recommended.
func ValidateAadhaar ¶
ValidateAadhaar checks if an Aadhaar number (Indian identification number) is valid. Aadhaar numbers must be exactly 12 digits, and the last digit is a checksum.
func ValidateInt ¶
ValidateInt checks if an integer with its checksum digit is valid.
func ValidateInt64 ¶
ValidateInt64 checks if an int64 with its checksum digit is valid.
func ValidateSlice ¶
ValidateSlice checks if a slice of digits with its checksum is valid.
func ValidateString ¶
ValidateString checks if a string number with its checksum digit is valid.
Types ¶
This section is empty.