🏗️ microservice fabric splitting

This commit is contained in:
2024-12-24 00:38:41 +08:00
parent 462e811742
commit 89d64336f5
311 changed files with 18384 additions and 2428 deletions

20
common/utils/encrypt.go Normal file
View File

@@ -0,0 +1,20 @@
package utils
import "golang.org/x/crypto/bcrypt"
// Encrypt 加密
func Encrypt(val string) (string, error) {
// 使用bcrypt库的GenerateFromPassword函数进行哈希处理
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(val), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(hashedPassword), err
}
// Verify 验证
func Verify(hashedVal string, val string) bool {
// 使用bcrypt库的CompareHashAndPassword函数比较密码
err := bcrypt.CompareHashAndPassword([]byte(hashedVal), []byte(val))
return err == nil
}