hasher

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Argon2id defines the argon2i hashing algorithm
	Argon2id = Algorithm(0x01)
	// Pbkdf2HmacSha512 defines pbkdf2+hmac-sha512 hashing algorithm
	Pbkdf2HmacSha512 = Algorithm(0x02)
	// Scrypt defines scrypt hashing algorithm
	Scrypt = Algorithm(0x03)
)

Variables

View Source
var Strategies = map[Algorithm]func(func() []byte) Strategy{
	Argon2id: func(salt func() []byte) Strategy {
		s, _ := newArgon2Deriver(salt(), argon2.IDKey)
		return s
	},
	Scrypt: func(salt func() []byte) Strategy {
		s, _ := newScryptDeriver(salt())
		return s
	},
	Pbkdf2HmacSha512: func(salt func() []byte) Strategy {
		s, _ := newPbkdf2Deriver(sha512.New, salt(), pbkdf2Iterations, sha512.Size)
		return s
	},
}

Strategies defines available hashing strategies

Functions

This section is empty.

Types

type Algorithm added in v1.0.2

type Algorithm uint8

Algorithm is the password hashing strategy code

type Metadata added in v1.0.2

type Metadata struct {
	Algorithm uint8  `cbor:"1,keyasint"`
	Version   uint8  `cbor:"2,keyasint"`
	Salt      []byte `cbor:"3,keyasint"`
	Hash      []byte `cbor:"4,keyasint"`
	// contains filtered or unexported fields
}

Metadata represents hasher result

func Decode added in v1.0.2

func Decode(r io.Reader) (*Metadata, error)

Decode metadata from string

func (*Metadata) Pack added in v1.0.2

func (m *Metadata) Pack() (string, error)

Pack metadata as BASE64URL CBOR payload

type Strategy

type Strategy interface {
	Hash([]byte) (*Metadata, error)
}

Strategy defines hash algorithm strategy contract

Jump to

Keyboard shortcuts

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