first commit

This commit is contained in:
William Bouzourène 2024-12-20 19:58:37 +01:00
commit 3d986c4ee2
27 changed files with 597 additions and 0 deletions

13
helpers/passwords.go Normal file
View file

@ -0,0 +1,13 @@
package helpers
import "golang.org/x/crypto/bcrypt"
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
return string(bytes), err
}
func CheckPasswordHash(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}