passwd

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2017 License: MIT Imports: 4 Imported by: 0

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