stackadler32

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

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

Go to latest
Published: Jan 4, 2018 License: MIT Imports: 0 Imported by: 5

README

stackadler32

Note: This is a fork of github.com/sent-hil/adler32 that provides digests that are allocated on the stack and can be incrementally written to. This is useful for places where you perform concurrent checksumming and there's no good place to cache a digest without needing to acquire it expensively (under lock, etc).

Port of adler32 checksum function as described here: https://www.ietf.org/rfc/rfc1950.txt to Go.

Example:

 adler32.Checksum([]byte("Hello World"))

Tests

$ go test
PASS
ok      github.com/sent-hil/adler32     2.429s

$ go test -bench=.
# This library is slightly faster than the one in standard library.
$ go test -bench=.
BenchmarkThis-4            10000            230169 ns/op
BenchmarkStdLib-4          10000            190834 ns/op
PASS
ok      github.com/sent-hil/adler32     6.554s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checksum

func Checksum(buf []byte) uint32

Checksum returns an adler32 checksum of the buffer specified.

Types

type Digest

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

Digest computes an adler32 hash and will very likely be allocated on the stack when used locally and not casted to an interface.

func NewDigest

func NewDigest() Digest

NewDigest returns an adler32 digest struct.

func (Digest) Sum32

func (d Digest) Sum32() uint32

Sum32 returns the currently computed adler32 hash.

func (Digest) Update

func (d Digest) Update(buf []byte) Digest

Update returns a new derived adler32 digest struct.

Jump to

Keyboard shortcuts

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