hash

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 0 Imported by: 0

README

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 ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash interface {
	Make(s string) (string, error)
	Check(s, hash string) bool
}

Hash hashing string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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