summaryrefslogtreecommitdiff
path: root/pkg/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/utils.go')
-rw-r--r--pkg/utils.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/utils.go b/pkg/utils.go
new file mode 100644
index 0000000..f5a443e
--- /dev/null
+++ b/pkg/utils.go
@@ -0,0 +1,13 @@
+package utils
+
+import "golang.org/x/crypto/bcrypt"
+
+func HashPassword(password string) (string, error) {
+ bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
+ return string(bytes), err
+}
+
+func CheckPasswordHash(password, hash string) bool {
+ err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
+ return err == nil
+}