bcrypt

package
v0.0.0-...-57de6aa Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package bcrypt implements a Django compatible bcrypt algorithm.

This is considered by many to be the most secure algorithm.

This library does not allow to set custom salt as in the Django algorithm. If you encode the same password multiple times you will get different hashes. This limitation comes from "golang.org/x/crypto/bcrypt" library.

A future release of this library may add support to custom salt.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHashComponentMismatch = errors.New("unchained/bcrypt: hashed password components mismatch")
	ErrAlgorithmMismatch     = errors.New("unchained/bcrypt: algorithm mismatch")
)

Errors returned by BCryptHasher.

Functions

This section is empty.

Types

type BCryptHasher

type BCryptHasher struct {
	// Algorithm identifier.
	Algorithm string
	// Defines the hash function used to avoid bcrypt's 72 bytes password truncation.
	Digest func() hash.Hash
	// Defines the number of rounds used to encode the password.
	Cost int
}

BCryptHasher implements Bcrypt password hasher.

func NewBCryptHasher

func NewBCryptHasher() *BCryptHasher

NewBCryptHasher secures password hashing using the bcrypt algorithm.

This hasher does not first hash the password which means it is subject to bcrypt's 72 bytes password truncation.

func NewBCryptSHA256Hasher

func NewBCryptSHA256Hasher() *BCryptHasher

NewBCryptSHA256Hasher secures password hashing using the bcrypt algorithm.

This hasher first hash the password with SHA-256.

func (*BCryptHasher) Encode

func (h *BCryptHasher) Encode(password string, salt string) (string, error)

Encode turns a plain-text password into a hash.

Parameter salt is currently ignored.

func (*BCryptHasher) Verify

func (h *BCryptHasher) Verify(password string, encoded string) (bool, error)

Verify if a plain-text password matches the encoded digest.

Jump to

Keyboard shortcuts

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