butcher: zntr.io/butcher/hasher Index | Files

package hasher

import "zntr.io/butcher/hasher"


Package Files

argon2_derivation.go definitions.go interface.go metadata.go pbkdf2_derivation.go scrypt_derivation.go


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)


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 {
            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

type Algorithm Uses

type Algorithm uint8

Algorithm is the password hashing strategy code

type Metadata Uses

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

Metadata represents hasher result

func Decode Uses

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

Decode metadata from string

func (*Metadata) Pack Uses

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

Pack metadata as BASE64URL CBOR payload

type Strategy Uses

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

Strategy defines hash algorithm strategy contract

Package hasher imports 13 packages (graph) and is imported by 1 packages. Updated 2020-06-10. Refresh now. Tools for package owners.