sha3

package standard library
go1.26.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: BSD-3-Clause Imports: 4 Imported by: 122

Documentation ΒΆ

Overview ΒΆ

Package sha3 implements the SHA-3 hash algorithms and the SHAKE extendable output functions defined in FIPS 202.

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func Sum224 ΒΆ

func Sum224(data []byte) [28]byte

Sum224 returns the SHA3-224 hash of data.

func Sum256 ΒΆ

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

Sum256 returns the SHA3-256 hash of data.

func Sum384 ΒΆ

func Sum384(data []byte) [48]byte

Sum384 returns the SHA3-384 hash of data.

func Sum512 ΒΆ

func Sum512(data []byte) [64]byte

Sum512 returns the SHA3-512 hash of data.

func SumSHAKE128 ΒΆ

func SumSHAKE128(data []byte, length int) []byte

SumSHAKE128 applies the SHAKE128 extendable output function to data and returns an output of the given length in bytes.

func SumSHAKE256 ΒΆ

func SumSHAKE256(data []byte, length int) []byte

SumSHAKE256 applies the SHAKE256 extendable output function to data and returns an output of the given length in bytes.

Types ΒΆ

type SHA3 ΒΆ

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

SHA3 is an instance of a SHA-3 hash. It implements hash.Hash. The zero value is a usable SHA3-256 hash.

func New224 ΒΆ

func New224() *SHA3

New224 creates a new SHA3-224 hash.

func New256 ΒΆ

func New256() *SHA3

New256 creates a new SHA3-256 hash.

func New384 ΒΆ

func New384() *SHA3

New384 creates a new SHA3-384 hash.

func New512 ΒΆ

func New512() *SHA3

New512 creates a new SHA3-512 hash.

func (*SHA3) AppendBinary ΒΆ

func (s *SHA3) AppendBinary(p []byte) ([]byte, error)

AppendBinary implements encoding.BinaryAppender.

func (*SHA3) BlockSize ΒΆ

func (s *SHA3) BlockSize() int

BlockSize returns the hash's rate.

func (*SHA3) Clone ΒΆ added in go1.25.0

func (d *SHA3) Clone() (hash.Cloner, error)

Clone implements hash.Cloner.

func (*SHA3) MarshalBinary ΒΆ

func (s *SHA3) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*SHA3) Reset ΒΆ

func (s *SHA3) Reset()

Reset resets the hash to its initial state.

func (*SHA3) Size ΒΆ

func (s *SHA3) Size() int

Size returns the number of bytes Sum will produce.

func (*SHA3) Sum ΒΆ

func (s *SHA3) Sum(b []byte) []byte

Sum appends the current hash to b and returns the resulting slice.

func (*SHA3) UnmarshalBinary ΒΆ

func (s *SHA3) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*SHA3) Write ΒΆ

func (s *SHA3) Write(p []byte) (n int, err error)

Write absorbs more data into the hash's state.

type SHAKE ΒΆ

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

SHAKE is an instance of a SHAKE extendable output function. The zero value is a usable SHAKE256 hash.

func NewCSHAKE128 ΒΆ

func NewCSHAKE128(N, S []byte) *SHAKE

NewCSHAKE128 creates a new cSHAKE128 XOF.

N is used to define functions based on cSHAKE, it can be empty when plain cSHAKE is desired. S is a customization byte string used for domain separation. When N and S are both empty, this is equivalent to NewSHAKE128.

func NewCSHAKE256 ΒΆ

func NewCSHAKE256(N, S []byte) *SHAKE

NewCSHAKE256 creates a new cSHAKE256 XOF.

N is used to define functions based on cSHAKE, it can be empty when plain cSHAKE is desired. S is a customization byte string used for domain separation. When N and S are both empty, this is equivalent to NewSHAKE256.

func NewSHAKE128 ΒΆ

func NewSHAKE128() *SHAKE

NewSHAKE128 creates a new SHAKE128 XOF.

func NewSHAKE256 ΒΆ

func NewSHAKE256() *SHAKE

NewSHAKE256 creates a new SHAKE256 XOF.

func (*SHAKE) AppendBinary ΒΆ

func (s *SHAKE) AppendBinary(p []byte) ([]byte, error)

AppendBinary implements encoding.BinaryAppender.

func (*SHAKE) BlockSize ΒΆ

func (s *SHAKE) BlockSize() int

BlockSize returns the rate of the XOF.

func (*SHAKE) MarshalBinary ΒΆ

func (s *SHAKE) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*SHAKE) Read ΒΆ

func (s *SHAKE) Read(p []byte) (n int, err error)

Read squeezes more output from the XOF.

Any call to Write after a call to Read will panic.

func (*SHAKE) Reset ΒΆ

func (s *SHAKE) Reset()

Reset resets the XOF to its initial state.

func (*SHAKE) UnmarshalBinary ΒΆ

func (s *SHAKE) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*SHAKE) Write ΒΆ

func (s *SHAKE) Write(p []byte) (n int, err error)

Write absorbs more data into the XOF's state.

It panics if any output has already been read.

Jump to

Keyboard shortcuts

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