hasher

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 13 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)
	// ScryptBlake2b512 defines scrypt+blake2b-512 hashing algorithm
	ScryptBlake2b512 = 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
	},
	ScryptBlake2b512: func(salt func() []byte) Strategy {
		s, _ := newScryptDeriver(func() hash.Hash {
			h, err := blake2b.New512(nil)
			if err != nil {
				panic(err.Error())
			}
			return h
		}, 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.1

type Algorithm uint8

Algorithm is the password hashing strategy code

type Metadata added in v1.0.1

type Metadata struct {
	Algorithm uint8
	Version   uint8
	Salt      []byte
	Hash      []byte
	// contains filtered or unexported fields
}

Metadata represents hasher result

func Decode added in v1.0.1

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

Decode metadata from string

func (*Metadata) Pack added in v1.0.1

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