hasher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 12 Imported by: 1

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 v0.1.0

type Algorithm uint8

Algorithm is the password hashing strategy code

type Metadata added in v0.1.0

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

Metadata represents hasher result

func Decode added in v0.1.0

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

Decode metadata from string

func (*Metadata) Encode added in v0.1.0

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

Encode 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