blob: 5f169af60cea68bd291a4c710353c49bd73271ee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package svc
import "golang.org/x/crypto/bcrypt"
// HashPass returns the bcrypt hash of the provided string.
// If an empty string is provided, return an empty string.
func HashPass(s string) (string, error) {
if s == "" {
return "", nil
}
h, err := bcrypt.GenerateFromPassword([]byte(s), 14)
if err != nil {
return "", err
}
return string(h), nil
}
|