feat: 新增函数工具

main
熊二 2 years ago
parent 6a5b54ced7
commit 39413b9a9c
  1. 13
      app/fns.go

@ -0,0 +1,13 @@
package app
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
}
Loading…
Cancel
Save