Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( NilHash = []byte("") NilCost = 0 )
Functions ¶
func GetSuitableCost ¶
Run a benchmark to get a suitable Cost for your application. The benchmark will take a few seconds. It will return the last Cost-value which is within your maxtime.
Types ¶
type BCryptWrapper ¶
type BCryptWrapper struct {
Cost int
}
func NewBCryptWrapper ¶
func NewBCryptWrapper(cost int) *BCryptWrapper
Returns a new BCrypt-Wrapper. Set Cost "NilCost" for running a benchmark and using the benchmark-outcome as Cost. The benchmark will then use 250ms as default value (meaning max amount of 4 passwords per second per thread).
func (*BCryptWrapper) CompareHashAndPassword ¶
func (wrapper *BCryptWrapper) CompareHashAndPassword(hashedPassword, password []byte) ([]byte, error)
Compares a password to a hashed password. Returns an bcrypt.ErrMismatchedHashAndPassword when password does not match the hash. Returns a newly hashed password when the Cost from the previous one used was lower then specified in this wrapper.
func (*BCryptWrapper) GenerateFromPassword ¶
func (wrapper *BCryptWrapper) GenerateFromPassword(password []byte) ([]byte, error)
Generates a hash value from a password. Uses the wrappers-Cost as Cost-value for bcrypt.