keys/bcrypt/bcrypt.go
func CompareHashAndPassword(hashedPassword, password []byte) error {
	p, err := newFromHash(hashedPassword)
	if err != nil {
		return err
	}

	otherHash, err := bcrypt(password, p.cost, p.salt)
	if err != nil {
		return err
	}

	otherP := &hashed{otherHash, p.salt, p.cost, p.major, p.minor}
	if subtle.ConstantTimeCompare(p.Hash(), otherP.Hash()) == 1 {
		return nil
	}

	return ErrMismatchedHashAndPassword
}
func CompareHashAndPassword(hashedPassword, password []byte) error {
	p, err := newFromHash(hashedPassword)
	if err != nil {
		return err
	}

	otherHash, err := bcrypt(password, p.cost, p.salt)
	if err != nil {
		return err
	}

	otherP := &hashed{otherHash, p.salt, p.cost, p.major, p.minor}
	if subtle.ConstantTimeCompare(p.Hash(), otherP.Hash()) == 1 {
		return nil
	}

	return ErrMismatchedHashAndPassword
}
func CompareHashAndPassword ( hashedPassword , password [ ] byte ) error { p , err := newFromHash ( hashedPassword ) if err != nil { return err } otherHash , err := bcrypt ( password , p . cost , p . salt ) if err != nil { return err } otherP := & hashed { otherHash , p . salt , p . cost , p . major , p . minor } if subtle . ConstantTimeCompare ( p . Hash ( ) , otherP . Hash ( ) ) == 1 { return nil } return ErrMismatchedHashAndPassword }
// CompareHashAndPassword compares a bcrypt hashed password with its possible
// plaintext equivalent. Returns nil on success, or an error on failure.
CompareHashAndPassword compares a bcrypt hashed password with its possible plaintext equivalent . Returns nil on success or an error on failure .