diff options
author | Benjamin Morrison <ben@gbmor.dev> | 2021-10-19 01:26:27 -0400 |
---|---|---|
committer | Benjamin Morrison <ben@gbmor.dev> | 2021-10-21 20:45:08 -0400 |
commit | dcb254618dc5541bb50c488c96b5e02c36951c06 (patch) | |
tree | 8fa5ec4bad0550d2bbad307da8fe8b89e0e06a17 /svc/common.go | |
parent | d2cbd7b2dca8b981f886c490d0aed205f0530c31 (diff) | |
download | getwtxt-dcb254618dc5541bb50c488c96b5e02c36951c06.tar.gz |
config for admin password, store bcrypt hash in confObj
Diffstat (limited to 'svc/common.go')
-rw-r--r-- | svc/common.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/svc/common.go b/svc/common.go new file mode 100644 index 0000000..5f169af --- /dev/null +++ b/svc/common.go @@ -0,0 +1,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 +} |