numkey

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package numkey is a Go wrapper for the numkey C software library. 64 bit Encoding for Short Codes and E.164 LVN.

@category Libraries @author Nicola Asuni @license see LICENSE file @link https://github.com/Vonage/numkey

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareNumKeyCountry

func CompareNumKeyCountry(nka, nkb uint64) int

CompareNumKeyCountry compares two NumKeys by country only.

func CountryKey

func CountryKey(country string) uint16

CountryKey encodes ISO 3166 alpha-2 country code into uint16.

func DecodeCountryKey

func DecodeCountryKey(ck uint16) string

DecodeCountryKey decodes countrykey into ISO 3166 alpha-2 country code.

func Hex

func Hex(v uint64) string

Hex provides a 16 digits hexadecimal string representation of a 64bit unsigned number.

func NumKey

func NumKey(country, number string) uint64

NumKey returns an encoded COUNTRY + NUMBER If the country or number are invalid this function returns 0

func ParseHex

func ParseHex(s string) uint64

ParseHex parses a 16 digit HEX string and returns the 64 bit unsigned number.

func PrefixKey

func PrefixKey(number string) uint64

PrefixKey encodes a number string into uint64. The encoded number is always 15 digits long as it is either right-padded with zeros or truncated. The prefixkey is safe to cast as int64 as it is always smaller than max int64.

func StringToNTBytesN

func StringToNTBytesN(s string, size int) []byte

StringToNTBytesN convert a string to byte array allocating "size" bytes.

Types

type TNumKey

type TNumKey struct {
	Country string `json:"country"`
	Number  string `json:"number"`
}

TNumKey contains the number components

func DecodeNumKey

func DecodeNumKey(nk uint64) TNumKey

DecodeNumKey parses a numkey string and returns the components as TNumKey structure.

Jump to

Keyboard shortcuts

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