hamac

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(mac Hmac, body []byte) []byte

Sign takes an Hmac (with secret, algorithm, and expected header), and a body, and returns an HTTP header, similar to GitHub and GitLab HMACs for authenticating the body, via HTTP header envelope. see https://tools.ietf.org/html/draft-cavage-http-signatures-10 or a later revision for more details on the proposed RFC specification.

Types

type Algorithm

type Algorithm int

restricted set of algorithms

const (
	Sha1 Algorithm = iota
	Sha256
	Sha512
)

type Hmac

type Hmac struct {
	Enabled   bool
	Algorithm Algorithm
	Header    string
	Secret    string
}

struct to hold validated hmac parameters and an overall enabled flag

func New

func New(input string) Hmac

New hmac will be enabled if all parameters are present and valid

Jump to

Keyboard shortcuts

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