1234567891011121314151617181920212223242526272829 |
- package utils
- import (
- "golang.org/x/crypto/bcrypt"
- )
- func BcryptEncrypt(password string) string {
- bytes, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
- return string(bytes)
- }
- func BcryptCheck(password, hash string) bool {
- err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
- return err == nil
- }
|