digest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 6 Imported by: 0

README

digest

Digest implement base on Instance Digests in HTTP

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DigestHashMD5    = &DigestHash{"MD5", crypto.MD5}
	DigestHashSha1   = &DigestHash{"SHA1", crypto.SHA1}
	DigestHashSha256 = &DigestHash{"SHA256", crypto.SHA256}
	DigestHashSha384 = &DigestHash{"SHA384", crypto.SHA384}
	DigestHashSha512 = &DigestHash{"SHA512", crypto.SHA512}
)
View Source
var ErrHashUnavailable = errors.New("the requested hash function is unavailable")

ErrHashUnavailable the requested hash function is unavailable

View Source
var ErrSignature = errors.New("the signature verify failure.")

ErrSignature the signature verify failure.

Functions

This section is empty.

Types

type Digest

type Digest interface {
	// returns the alg identifier for this digest.
	Alg() string
	// Returns nil if sign is valid,
	// value format always `algorithm=<encoded digest output with base64>`
	Sign(p []byte) (string, error)
	// same as Sign
	SignReader(r io.Reader) (string, error)
	// Returns nil if signature is valid
	Verify(p []byte, sig string) error
	// same as Verify
	VerifyReader(r io.Reader, sig string) error
}

Digest can be used sign an input. The sign is then usually base64 encoded.

type DigestHash

type DigestHash struct {
	Name string
	Hash crypto.Hash
}

func (*DigestHash) Alg

func (m *DigestHash) Alg() string

func (*DigestHash) Sign

func (m *DigestHash) Sign(p []byte) (string, error)

func (*DigestHash) SignReader

func (m *DigestHash) SignReader(r io.Reader) (string, error)

func (*DigestHash) Verify

func (m *DigestHash) Verify(p []byte, sig string) error

func (*DigestHash) VerifyReader

func (m *DigestHash) VerifyReader(r io.Reader, sig string) error

Jump to

Keyboard shortcuts

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