password

package
v0.0.0-...-b44aec9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CurrentVersion of the Hasher used, if the versions do not match
	// the previous function is used and replaced by a
	// hash from the current Hasher.
	CurrentVersion int

	// CurrentHasher is the default Hasher to be used.
	CurrentHasher Hasher

	// Previous are used when the Password do not match the
	// CurrentVersion.
	Previous map[int]Hasher
)

Functions

func Check

func Check(password Password, provided string) (bool, error)

Check a Password againts a string.

func Update

func Update(password Password, provided string) error

Update the password with the provided string

Types

type Bcrypt

type Bcrypt struct {
	//If the cost given is 0 or less than bcrypt.MinCost then bcrypt.Default
	// will be used.
	Cost int
}

Bcrypt implements a bcrypt Hasher

func (Bcrypt) Compare

func (b Bcrypt) Compare(h []byte, p string) bool

Compare a []byte hash to a string

func (Bcrypt) Hash

func (b Bcrypt) Hash(s string) ([]byte, error)

Hash a []byte hash from a string

type Hasher

type Hasher interface {
	Hash(string) ([]byte, error)
	Compare([]byte, string) bool
}

Hasher is an interface implements a method to generate a Hash from a string and a method to compare a Hash to a string

type Password

type Password interface {
	PasswordBytes() []byte
	PasswordVersion() int
	PasswordSet([]byte, int) error
}

Password allows acces to the user's password.

Jump to

Keyboard shortcuts

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