From 69af8ddbdff8e6d0dd551e9bdc72284469a86fc0 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Sun, 3 Jul 2022 15:36:17 -0700 Subject: Minor cleanup --- hotline/account.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'hotline/account.go') diff --git a/hotline/account.go b/hotline/account.go index a680861..9a0fb7d 100644 --- a/hotline/account.go +++ b/hotline/account.go @@ -3,6 +3,7 @@ package hotline import ( "encoding/binary" "golang.org/x/crypto/bcrypt" + "log" ) const GuestAccount = "guest" // default account used when no login is provided for a connection @@ -37,3 +38,13 @@ func (a *Account) Read(p []byte) (n int, err error) { return len(p), nil } + +// hashAndSalt generates a password hash from a users obfuscated plaintext password +func hashAndSalt(pwd []byte) string { + hash, err := bcrypt.GenerateFromPassword(pwd, bcrypt.MinCost) + if err != nil { + log.Println(err) + } + + return string(hash) +} -- cgit