package bcrypt func newFromPasswordAndSalt(password, unencodedSalt []byte, cost int) (*hashed, error) { if cost < MinCost { cost = DefaultCost } p := new(hashed) p.major = majorVersion p.minor = minorVersion err := checkCost(cost) if err != nil { return nil, err } p.cost = cost p.salt = unencodedSalt hash, err := bcrypt(password, p.cost, p.salt) if err != nil { return nil, err } p.hash = hash return p, err } /* This function is necessary because mbcrypt needs to control the salt (like you can with other KDFs). All other bcrypt source remains unmodified from the original x/crypto/bcrypt. */ func GenerateFromPasswordAndSalt(password, rawSalt []byte, cost int) ([]byte, error) { p, err := newFromPasswordAndSalt(password, rawSalt, cost) if err != nil { return nil, err } return p.Hash(), nil }