sha2

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package sha2 provides hashing and verification of SHA-256 and SHA-512 encoded passwords with salt based on crypt(3). [The algorithm](https://www.akkadia.org/drepper/SHA-crypt.txt) builds hashes through multiple digest iterations with shuffles of password and salt.

Index

Constants

View Source
const (
	Sha256Identifier = "$5$"
	Sha512Identifier = "$6$"
	SaltLenMin       = 1
	SaltLenMax       = 16
	RoundsMin        = 1000
	RoundsMax        = 999999999
	RoundsDefault    = 5000
)

Variables

Verifier for sha2.

Functions

func Verify

func Verify(encoded, password string) (verifier.Result, error)

Verify parses encoded and uses its parameters to verify password against its hash.

Types

type Hasher

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

Hasher hashes and verifies crypt(3) style SHA256 and SHA512 passwords.

func New256

func New256(rounds int) *Hasher

func New512

func New512(rounds int) *Hasher

func (*Hasher) Hash

func (h *Hasher) Hash(password string) (string, error)

Hash implements passwap.Hasher.

func (*Hasher) Verify

func (h *Hasher) Verify(encoded, password string) (verifier.Result, error)

Verify implements passwap.Verifier

Jump to

Keyboard shortcuts

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