blake256

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 2 Imported by: 2

README

blake256

Go Reference Test Coverage Status

Go implementation of BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).

Install

go get github.com/KarpelesLab/blake256

Usage

package main

import (
	"fmt"

	"github.com/KarpelesLab/blake256"
)

func main() {
	// One-shot hash
	hash := blake256.Sum256([]byte("hello"))
	fmt.Printf("%x\n", hash)

	// Streaming hash
	h := blake256.New()
	h.Write([]byte("hello"))
	fmt.Printf("%x\n", h.Sum(nil))

	// With salt (16 bytes)
	h, err := blake256.NewSalt([]byte("0123456789abcdef"))
	if err != nil {
		panic(err)
	}
	h.Write([]byte("hello"))
	fmt.Printf("%x\n", h.Sum(nil))
}
BLAKE-224
hash := blake256.Sum224([]byte("hello"))
h := blake256.New224()

Features

  • BLAKE-256 and BLAKE-224 hash computation
  • Implements hash.Hash, encoding.BinaryMarshaler, and encoding.BinaryUnmarshaler
  • Optional 16-byte salt support via NewSalt / New224Salt
  • Zero external dependencies

License

MIT License. See LICENSE for details.

Documentation

Overview

Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).

Index

Constants

View Source
const BlockSize = 64

BlockSize is the block size of the hash algorithm in bytes.

View Source
const Size = 32

Size is the size of BLAKE-256 hash in bytes.

View Source
const Size224 = 28

Size224 is the size of BLAKE-224 hash in bytes.

Variables

This section is empty.

Functions

func New

func New() hash.Hash

New returns a new hash.Hash computing the BLAKE-256 checksum.

func New224

func New224() hash.Hash

New224 returns a new hash.Hash computing the BLAKE-224 checksum.

func New224Salt

func New224Salt(salt []byte) (hash.Hash, error)

New224Salt is like New224 but initializes salt with the given 16-byte slice.

func NewSalt

func NewSalt(salt []byte) (hash.Hash, error)

NewSalt is like New but initializes salt with the given 16-byte slice.

func Sum224

func Sum224(data []byte) (sum224 [Size224]byte)

Sum224 returns the BLAKE-224 checksum of the data.

func Sum256

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

Sum256 returns the BLAKE-256 checksum of the data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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