sri

package
v2.34.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package sri implements helper functions to calculate SubResource Integrity hashes. https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity

Index

Constants

View Source
const (
	// SHA256 algo
	SHA256 = Algo("sha256")
	// SHA384 algo
	SHA384 = Algo("sha384")
	// SHA512 algo
	SHA512 = Algo("sha512")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Algo

type Algo string

Algo is a supported hashing algorithm

type Hash

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

Hash represents a SRI-hash

func Parse

func Parse(sriHash string) (*Hash, error)

Parse a SRI hash

func (*Hash) Hex

func (h *Hash) Hex() string

Hex return a hex-encoded representation of the sum

func (*Hash) String

func (h *Hash) String() string

String returns a SRI-encoded string

type Writer

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

Writer is like a hash.Hash with a Sum function

func NewWriter

func NewWriter(w io.Writer, algo Algo) Writer

NewWriter returns a SRI writer that forwards the write while calculating the SRI hash.

func (Writer) Sum

func (w Writer) Sum() *Hash

Sum returns the calculated SRI hash

func (Writer) Write

func (w Writer) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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