password

package
v0.0.0-...-5805fc1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLength = 16

DefaultLength is the length chosen by Generate in case the passed length is smaller than MinLength.

View Source
const MaxLength = 2048

MaxLength is the maximum length for any password to be generated, hashed, or checked by functions in this package.

View Source
const MinLength = 10

MinLength is the minimum length for any password to be generated, hashed, or checked by functions in this package.

Variables

This section is empty.

Functions

func Check

func Check(password, hash []byte) (err error)

Check compares the given password (plaintext) against some hash. It will return nil if password and hash match.

func CheckLen

func CheckLen(password []byte) error

func Generate

func Generate(n int) (password []byte, err error)

Generate produces a cryptographically strong random slice of bytes. If n is lower than MinLength it is set to DefaultLength.

func Hash

func Hash(password []byte) (hash []byte, err error)

Hash computes a hash from the given password.

Types

type InvalidPasswordLengthError

type InvalidPasswordLengthError int

InvalidPasswordLengthError is returned by Hash and Check in case the given plaintext password is too short or too long. Generate is guaranteed to produce passwords that adhere to those limits.

func (InvalidPasswordLengthError) Error

func (ipl InvalidPasswordLengthError) Error() string

Jump to

Keyboard shortcuts

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