blob: d24183d62ec43a9a0f6a4715895052072f25ca37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
package database
import "golang.org/x/crypto/bcrypt"
// To allow for testing the error case (bad random is hard to trigger)
var passwordFunction = bcrypt.GenerateFromPassword
func hashPassword(password string) (string, error) {
bytes, err := passwordFunction([]byte(password), bcrypt.DefaultCost)
if err != nil {
return "", newPasswordError(err)
}
return string(bytes), nil
}
|