passwd

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2017 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyPassword means that an empty password was given.
	ErrEmptyPassword = errors.New("empty password")
)

Functions

func ComparePassword

func ComparePassword(hash, password []byte) error

ComparePassword compares a given password with the given hash.

func ComparePasswordString

func ComparePasswordString(hash []byte, password string) error

ComparePasswordString compares a given password string with the given hash.

func DecodePasswordHash

func DecodePasswordHash(encoded string) (decoded []byte, err error)

DecodePasswordHash takes a base64-encoded password hash and returns the appropriate bytes.

func GenerateEncodedPassword

func GenerateEncodedPassword(passwd string) (encoded string, err error)

GenerateEncodedPassword returns an encrypted password, encoded into a string with base64.

func NewSalt

func NewSalt() ([]byte, error)

NewSalt returns a salt for crypto uses.

Types

type SaltedManager

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

SaltedManager supports the hashing and comparing of passwords with the given salt.

func NewSaltedManager

func NewSaltedManager(salt []byte) SaltedManager

NewSaltedManager returns a new SaltedManager with the given salt.

func (*SaltedManager) CompareHashAndPassword

func (sm *SaltedManager) CompareHashAndPassword(hashedPassword []byte, specialSalt []byte, password string) error

CompareHashAndPassword compares a hashed password with its possible plaintext equivalent. Returns nil on success, or an error on failure.

func (*SaltedManager) GenerateFromPassword

func (sm *SaltedManager) GenerateFromPassword(specialSalt []byte, password string) ([]byte, error)

GenerateFromPassword encrypts the given password.

Jump to

Keyboard shortcuts

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