diff options
Diffstat (limited to 'password/hash.go')
-rw-r--r-- | password/hash.go | 11 |
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 +} |