From a6826055bf4e6a23f80da047ccfe4509a209f3a6 Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 29 Mar 2020 16:10:59 +0530 Subject: Initial perseus rewrite --- password/hash.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 password/hash.go (limited to 'password/hash.go') 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 +} -- cgit 1.4.1-2-gfad0