idcheck

package module
v0.0.0-...-e4b661b Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: MIT Imports: 4 Imported by: 4

Documentation

Overview

Package idcheck generates ids that can be verified using the final byte as a checksum.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetIDReader

func SetIDReader(idReader io.Reader)

SetIDReader Sets the reader used to generate new IDs

func SetSalt

func SetSalt(salt string)

SetSalt sets the salt to use in hash calculations

func ValidID

func ValidID(id *ID) bool

ValidID returns true if the ID has the correct length and checksum

Types

type ID

type ID [length]byte

ID is an id

func FromBase64

func FromBase64(str string) (*ID, error)

FromBase64 creates a new ID from a base64 encoded string

func NewID

func NewID() (*ID, error)

NewID creates a new ID of default length with a random value

func (*ID) Base64

func (id *ID) Base64() string

Base64 encodes an ID as a base64 string

type IDChecker

type IDChecker interface {
	NewID() (*ID, error)
	ValidID(id *ID) bool
}

IDChecker issues and validates IDs

func NewIDChecker

func NewIDChecker(options ...Option) IDChecker

NewIDChecker returns a new IDChecker

type Option

type Option func(*idChecker)

Option is an option for creating IDs

func Reader

func Reader(reader io.Reader) Option

Reader use reader to create new IDs instead of the default rand.Reader

func Salt

func Salt(salt string) Option

Salt sets the salt to use in hash calculations

Jump to

Keyboard shortcuts

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