server: implement working db transaction with users
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package api
|
||||
|
||||
import "golang.org/x/crypto/bcrypt"
|
||||
|
||||
func hashPassword(password string) (string, error) {
|
||||
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password),
|
||||
bcrypt.DefaultCost)
|
||||
return string(hashedPassword), err
|
||||
}
|
||||
|
||||
func validatePassword(hashedPassword, password string) error {
|
||||
return bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
|
||||
}
|
||||
Reference in New Issue
Block a user