sri

package module
v0.0.0-...-ab6d4fa Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 9 Imported by: 0

README

sri GoDoc Build Status Go Report Card

sri computes the SHA256/384/512 sum for a list of files, writing each line as NDJSON to a given io.Writer

install

go get github.com/kasperlewau/base62

usage

cli
$ find . -maxdepth 1 -type f | sri > shasums.json
library
import "github.com/kasperlewau/sri"

func main() {
	b := []byte(`myfile.txt`)
	if err := sri.Hash(bytes.NewReader(b), os.Stdout); err != nil {
		panic(err)
	}
}

License

MIT

Documentation

Overview

Package sri provides the means to compute sub-resource-integrity sha sums for a list of files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(src io.Reader, dest io.Writer) error

Hash computes the SHA256/384/512 sum for a list of files and writes each line as NDJSON to the given writer If an error occurs, Hash wont run to completion and the error will be returned immediately

Types

type Resource

type Resource struct {
	Path   string    `json:"path"`
	Sha256 hash.Hash `json:"sha_256"`
	Sha384 hash.Hash `json:"sha_384"`
	Sha512 hash.Hash `json:"sha_512"`
}

Resource is a named file with sub-resource-integrity hashes combined

func (*Resource) MarshalJSON

func (r *Resource) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Resource into JSON, hex encoding the SHAsums

func (*Resource) Reset

func (r *Resource) Reset()

Reset resets the hashes of a Resource and zero-s out the filename

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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