aboutsummaryrefslogtreecommitdiff
path: root/backend/hashing
diff options
context:
space:
mode:
authorRyan Mehri <[email protected]>2020-05-10 17:32:31 -0600
committerRyan Mehri <[email protected]>2020-05-10 17:32:31 -0600
commit01d3631b893b09ec4c5f9daade727e8f88aa8d22 (patch)
treee35a25eef106f58ebc7d222e3f51ac5013f04f6e /backend/hashing
parentUpdate post to return hash and password (diff)
downloadctrl-v-01d3631b893b09ec4c5f9daade727e8f88aa8d22.tar.xz
ctrl-v-01d3631b893b09ec4c5f9daade727e8f88aa8d22.zip
Add password hashing
Diffstat (limited to 'backend/hashing')
-rw-r--r--backend/hashing/hash.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/backend/hashing/hash.go b/backend/hashing/hash.go
index 400659e..93a9cf9 100644
--- a/backend/hashing/hash.go
+++ b/backend/hashing/hash.go
@@ -3,6 +3,7 @@ package hashing
import (
"crypto/md5"
"encoding/hex"
+ "golang.org/x/crypto/bcrypt"
"math/big"
"time"
)
@@ -23,4 +24,9 @@ func hashString(text string) string {
bi := big.NewInt(0)
bi.SetString(hexStr, 16)
return bi.Text(62)
+}
+
+func HashPassword(password string) (string, error) {
+ hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
+ return string(hashedPassword), err
} \ No newline at end of file