/hash-go

Go abstraction for hashing a string

Primary LanguageGoMIT LicenseMIT

hash-go

Go abstraction for hashing a string

Install

$ go get github.com/garavan/hash-go

Usage

import (
	hash "github.com/garavan/hash-go"
	bcryptHash "github.com/garavan/hash-go/bcrypt"
)

type userService struct {
	hash hash.Hash
}

func NewUserService(hash hash.Hash) User {
	return &userService{hash}
}

func (u *userService) Create(data map[string]string) error {
	passHashed, err := u.hash.Make(data["password"])
	...
}


userSrv := NewUserService(bcryptHash.DefaultBcryptHash())
...

Methods

  1. bcrypt

Test

$ go test ./...