signature

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Header = `Signature`
)

Variables

View Source
var (
	ErrInvalidSignature = errors.New("invalid signature header")
)

Functions

func Encode

func Encode(h http.Header, s Signature, body []byte)

Encode make and setting signature to header

Types

type Data

type Data struct {
	ID   string
	Alg  string
	Hash string
}

func Decode

func Decode(h http.Header) (s Data, err error)

Decode getting signature from header

type Signature

type Signature interface {
	ID() string
	Algorithm() string
	Create(b []byte) []byte
	CreateString(b []byte) string
	Validate(b []byte, ex string) bool
}

Signature interface

func NewCustomSignature

func NewCustomSignature(id, secret, alg string, h func() hash.Hash) Signature

NewCustomSignature create sign with custom hash function

func NewMD5

func NewMD5(id, secret string) Signature

NewMD5 create sign md5

func NewSHA256

func NewSHA256(id, secret string) Signature

NewSHA256 create sign sha256

func NewSHA512

func NewSHA512(id, secret string) Signature

NewSHA512 create sign sha512

type Storage

type Storage interface {
	Add(s Signature)
	Get(id string) Signature
	Count() int
	Del(id string)
	Flush()
}

_store storage

func NewStorage

func NewStorage() Storage

NewStorage init storage

Jump to

Keyboard shortcuts

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