feat: полная реализация

This commit is contained in:
2026-11-10 15:27:10 +03:00
parent 7734b222f8
commit 5cf99b5384
18 changed files with 935 additions and 211 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
}