summary refs log tree commit diff stats
path: root/password/hash.go
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-29 16:10:59 +0530
committerAndinus <andinus@nand.sh>2020-03-29 16:10:59 +0530
commita6826055bf4e6a23f80da047ccfe4509a209f3a6 (patch)
treef2bb2bec35ee5e61cb42f4edffb04368a0f8ba60 /password/hash.go
parent7b95d6b80dd2d1efb26f7c515383abd4f0dc9d42 (diff)
downloadperseus-a6826055bf4e6a23f80da047ccfe4509a209f3a6.tar.gz
Initial perseus rewrite
Diffstat (limited to 'password/hash.go')
-rw-r--r--password/hash.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/password/hash.go b/password/hash.go
new file mode 100644
index 0000000..3dd949b
--- /dev/null
+++ b/password/hash.go
@@ -0,0 +1,11 @@
+package password
+
+import "golang.org/x/crypto/bcrypt"
+
+// Hash takes a string as input and returns the hash of the
+// password.
+func Hash(password string) (string, error) {
+	// 10 is the default cost.
+	out, err := bcrypt.GenerateFromPassword([]byte(password), 10)
+	return string(out), err
+}