bff config to nacos
CI / changes (push) Successful in 2s
CI / docker-bff (push) Successful in 3m7s
CI / docker-product (push) Has been skipped
CI / docker-admin (push) Successful in 3m26s

This commit is contained in:
2026-08-13 16:27:18 +08:00
parent 94e1c6f97d
commit 6c20427b0a
19 changed files with 458 additions and 169 deletions
+3 -45
View File
@@ -5,9 +5,8 @@ import (
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"math/rand"
"strings"
"time"
"pkg.local/utils"
)
var (
@@ -21,47 +20,6 @@ func Init(debug bool, key string) {
encryptKey = key
}
func GetConfigBool(key string) bool {
if key == "base.is_debug" {
return isDebug
}
return false
}
func GetConfigString(key string) string {
if key == "encrypt.encrypt_key" {
return encryptKey
}
return ""
}
func GetEncrypt(key string, nums ...int8) string {
original := GetConfigString(key)
str := original
//TODO 后台切换到新版时开启
//for _, num := range nums {
// str = str[num:] + str[:num]
//}
return str
}
// GetRandString 取得随机字符串:使用字符串拼接
func GetRandString(length int) string {
if length < 1 {
return ""
}
char := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
charArr := strings.Split(char, "")
charlen := len(charArr)
ran := rand.New(rand.NewSource(time.Now().Unix()))
var rchar string = ""
for i := 1; i <= length; i++ {
rchar = rchar + charArr[ran.Intn(charlen)]
}
return rchar
}
type Crypto struct{}
// EncryptKey 加密
@@ -76,7 +34,7 @@ func (c Crypto) EncryptKey(data []byte, key string) (map[string]string, Error) {
func (c Crypto) aesCBCEncryptKey(data []byte, key string) (map[string]string, Error) {
k := []byte(key)
iv := GetRandString(NumberSixteen)
iv := utils.GetRandString(NumberSixteen)
// 分组密钥
block, err := aes.NewCipher(k)