hasher

package
v0.0.0-...-2d64e5c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Simple wrapper around golang's bcrypt library

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BcryptHasher

type BcryptHasher struct {
	// contains filtered or unexported fields
}

func NewBcryptHasher

func NewBcryptHasher(cost int) *BcryptHasher

func (*BcryptHasher) Hash

func (b *BcryptHasher) Hash(p string) (string, error)

Some cryptic hash value would be the first return value of the expression While an error would be the second. The hash was successful only if the error equals nil

Example
hasher := &BcryptHasher{19}

hasher.Hash("*72t723c(#fji3)@")
Output:

func (*BcryptHasher) Verify

func (b *BcryptHasher) Verify(hashed, plain string) bool
Example
badPassword := "my-password"

hasher := &BcryptHasher{10}

hashedPassword, _ := hasher.Hash(badPassword)

fmt.Println(hasher.Verify(hashedPassword, badPassword))
Output:

true

type Hasher

type Hasher interface {
	Hash(p string) (string, error)
	Verify(hashed, plain string) bool
}

Jump to

Keyboard shortcuts

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