scrypt

package
v0.0.0-...-70049d7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package scrypt provides salt generation, hashing and verification for x/crypto/scrypt.

Index

Constants

View Source
const (
	Identifier       = "scrypt"
	Identifier_Linux = "7"
	Prefix           = "$" + Identifier + "$"
	Prefix_Linux     = "$" + Identifier_Linux + "$"
)

Identifiers and prefixes that describe and scrypt encoded hash string.

View Source
const Format = "$%s$ln=%d,r=%d,p=%d$%s$%s"

Format of the Modular Crypt Format, as used by passlib. See https://passlib.readthedocs.io/en/stable/lib/passlib.hash.scrypt.html#format-algorithm

Variables

View Source
var (
	RecommendedParams = Params{
		N:       32768,
		R:       8,
		P:       1,
		KeyLen:  32,
		SaltLen: 16,
	}
)

Verifier for Scrypt.

Functions

func Verify

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

Verify parses encoded and uses its scrypt parameters to verify password against its hash. Either the result of Fail or OK is returned, or an error if parsing fails.

Types

type Hasher

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

func New

func New(p Params) *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

type Params

type Params struct {
	// N, R, P are the cost parameters used
	// by scrypt.Key:
	// https://pkg.go.dev/golang.org/x/crypto/scrypt#Key
	N int
	R int
	P int

	// Lengths for key output and desired salt.
	KeyLen  int
	SaltLen uint32
}

Jump to

Keyboard shortcuts

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