signature

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SignHeader = `Signature`
)

Variables

This section is empty.

Functions

func Encode

func Encode(h http.Header, s SignGetter, 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 SignGetter

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

SignGetter interface

type Signature

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

Signature model

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

func (*Signature) Algorithm

func (s *Signature) Algorithm() string

Algorithm getter

func (*Signature) Create

func (s *Signature) Create(b []byte) []byte

Create getting hash as bytes

func (*Signature) CreateString

func (s *Signature) CreateString(b []byte) string

CreateString getting hash as string

func (*Signature) ID

func (s *Signature) ID() string

ID signature

func (*Signature) Validate

func (s *Signature) Validate(b []byte, ex string) bool

Validate signature

type Storage

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

Storage storage

func NewStorage

func NewStorage() *Storage

NewStorage init storage

func (*Storage) Add

func (ss *Storage) Add(s SignGetter)

Add adding to storage

func (*Storage) Count

func (ss *Storage) Count() int

Count count sign in storage

func (*Storage) Del

func (ss *Storage) Del(id string)

Del deleting from storage

func (*Storage) Flush

func (ss *Storage) Flush()

Flush removing all from storage

func (*Storage) Get

func (ss *Storage) Get(id string) SignGetter

Get getting to storage

Jump to

Keyboard shortcuts

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