Added authorization

This commit is contained in:
KamilM1205 2025-09-25 09:01:00 +04:00
parent c3c3d65d32
commit b96dd39795
50 changed files with 685 additions and 410 deletions

View file

@ -6,9 +6,10 @@ import (
"golang.org/x/crypto/bcrypt"
)
const salt = "58_team:%s:1205secret"
func EncryptPassword(pass string) (string, error) {
var salted string
salt := "58_team:%s:1205secret"
salted = fmt.Sprintf(salt, pass)
@ -19,3 +20,14 @@ func EncryptPassword(pass string) (string, error) {
return string(hashed), nil
}
func CheckPassword(pass_hashed string, pass string) bool {
salted := fmt.Sprintf(salt, pass)
err := bcrypt.CompareHashAndPassword([]byte(pass_hashed), []byte(salted))
if err != nil {
return false
}
return true
}