feat: база из лабораторной 3 перенесена в лабу 4

This commit is contained in:
2026-11-10 16:24:08 +03:00
parent ec540a1a72
commit fc3ab1ca38
27 changed files with 1273 additions and 1374 deletions
+17
View File
@@ -0,0 +1,17 @@
package password
import "golang.org/x/crypto/bcrypt"
const bcryptCost = 10
func Hash(password string) (string, error) {
hashed, err := bcrypt.GenerateFromPassword([]byte(password), bcryptCost)
if err != nil {
return "", err
}
return string(hashed), nil
}
func Check(password, hash string) bool {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil
}