go-hashids: github.com/speps/go-hashids Index | Files

package hashids

import "github.com/speps/go-hashids"

Index

Package Files

hashids.go

Constants

const (
    // Version is the version number of the library
    Version string = "1.0.0"

    // DefaultAlphabet is the default alphabet used by go-hashids
    DefaultAlphabet string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
)

type HashID Uses

type HashID struct {
    // contains filtered or unexported fields
}

HashID contains everything needed to encode/decode hashids

func New Uses

func New() (*HashID, error)

New creates a new HashID

func NewWithData Uses

func NewWithData(data *HashIDData) (*HashID, error)

NewWithData creates a new HashID with the provided HashIDData

func (*HashID) Decode Uses

func (h *HashID) Decode(hash string) []int

DEPRECATED: Use DecodeWithError instead Decode unhashes the string passed to an array of int. It is symmetric with Encode if the Alphabet and Salt are the same ones which were used to hash. MinLength has no effect on Decode.

func (*HashID) DecodeInt64 Uses

func (h *HashID) DecodeInt64(hash string) []int64

DEPRECATED: Use DecodeInt64WithError instead DecodeInt64 unhashes the string passed to an array of int64. It is symmetric with EncodeInt64 if the Alphabet and Salt are the same ones which were used to hash. MinLength has no effect on DecodeInt64.

func (*HashID) DecodeInt64WithError Uses

func (h *HashID) DecodeInt64WithError(hash string) ([]int64, error)

DecodeInt64 unhashes the string passed to an array of int64. It is symmetric with EncodeInt64 if the Alphabet and Salt are the same ones which were used to hash. MinLength has no effect on DecodeInt64.

func (*HashID) DecodeWithError Uses

func (h *HashID) DecodeWithError(hash string) ([]int, error)

Decode unhashes the string passed to an array of int. It is symmetric with Encode if the Alphabet and Salt are the same ones which were used to hash. MinLength has no effect on Decode.

func (*HashID) Encode Uses

func (h *HashID) Encode(numbers []int) (string, error)

Encode hashes an array of int to a string containing at least MinLength characters taken from the Alphabet. Use Decode using the same Alphabet and Salt to get back the array of int.

func (*HashID) EncodeInt64 Uses

func (h *HashID) EncodeInt64(numbers []int64) (string, error)

EncodeInt64 hashes an array of int64 to a string containing at least MinLength characters taken from the Alphabet. Use DecodeInt64 using the same Alphabet and Salt to get back the array of int64.

type HashIDData Uses

type HashIDData struct {
    // Alphabet is the alphabet used to generate new ids
    Alphabet string

    // MinLength is the minimum length of a generated id
    MinLength int

    // Salt is the secret used to make the generated id harder to guess
    Salt string
}

HashIDData contains the information needed to generate hashids

func NewData Uses

func NewData() *HashIDData

NewData creates a new HashIDData with the DefaultAlphabet already set.

Package hashids imports 4 packages (graph) and is imported by 17 packages. Updated 2017-07-06. Refresh now. Tools for package owners.