feat: 加密工具AES-CBC,配合前端CryptoJS加解密
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"be.ems/src/framework/config"
|
||||
"be.ems/src/framework/constants/common"
|
||||
"be.ems/src/framework/logger"
|
||||
"be.ems/src/framework/utils/cmd"
|
||||
@@ -68,7 +69,8 @@ func codeFileRead() (map[string]any, error) {
|
||||
}
|
||||
content := string(bytes)
|
||||
// 解密
|
||||
contentDe, err := crypto.StringDecryptByAES(content)
|
||||
hostKey := config.Get("aes.hostKey").(string)
|
||||
contentDe, err := crypto.AESDecryptBase64(content, hostKey)
|
||||
if err != nil {
|
||||
logger.Errorf("CodeFileRead decrypt: %v", err.Error())
|
||||
return mapData, fmt.Errorf("decrypt fail")
|
||||
@@ -86,7 +88,8 @@ func codeFileRead() (map[string]any, error) {
|
||||
func codeFileWrite(data map[string]any) error {
|
||||
jsonByte, _ := json.Marshal(data)
|
||||
// 加密
|
||||
contentEn, err := crypto.StringEncryptByAES(string(jsonByte))
|
||||
hostKey := config.Get("aes.hostKey").(string)
|
||||
contentEn, err := crypto.AESEncryptBase64(string(jsonByte), hostKey)
|
||||
if err != nil {
|
||||
logger.Errorf("insert encrypt: %v", err.Error())
|
||||
return fmt.Errorf("encrypt fail")
|
||||
|
||||
Reference in New Issue
Block a user