This repository has been archived on 2026-01-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2025-07-06 16:46:21 +03:00
|
|
|
package hash
|
2025-07-05 22:17:14 +03:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|