123456789101112131415 |
- package hash
- import (
- "golang.org/x/crypto/bcrypt"
- )
- func HashPassword(password string) string {
- bytes, _ := bcrypt.GenerateFromPassword([]byte(password), 14)
- return string(bytes)
- }
- func CheckPasswordHash(password, hash string) bool {
- err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
- return err == nil
- }
|