sha256

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package sha256 implements SHA-256 (FIPS 180-4).

It exists for size, not for secrecy. Nothing here is a secret — the input is a version string and the output is a picture — but crypto/sha256 now arrives with the FIPS-140 module's self-tests, entropy sources and runtime checks behind it, which is about a sixth of a megabyte in a binary whose only job is to draw a mark. The algorithm itself is a fixed standard, so owning it costs nothing in drift: the digests are the same digests, and a test checks that against crypto/sha256 for every input the library uses.

Index

Constants

View Source
const BlockSize = 64

BlockSize is the algorithm's block size in bytes.

View Source
const Size = 32

Size is the length of a SHA-256 digest in bytes.

Variables

This section is empty.

Functions

func Sum256

func Sum256(data []byte) [Size]byte

Sum256 returns the digest of data.

Types

type Digest

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

Digest is an in-progress SHA-256 computation. Its method set is the part of hash.Hash the library uses, so callers read the same as they did against crypto/sha256.

func New

func New() *Digest

New returns a Digest ready to hash.

func (*Digest) BlockSize

func (d *Digest) BlockSize() int

BlockSize returns the algorithm's block size in bytes.

func (*Digest) Reset

func (d *Digest) Reset()

Reset returns the Digest to its initial state.

func (*Digest) Size

func (d *Digest) Size() int

Size returns the digest length in bytes.

func (*Digest) Sum

func (d *Digest) Sum(b []byte) []byte

Sum appends the digest of everything written so far to b, leaving the Digest itself usable for further writes.

func (*Digest) Write

func (d *Digest) Write(p []byte) (int, error)

Write adds more data to the running digest. It never returns an error.

Jump to

Keyboard shortcuts

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