XinYeYouKu/app/services/XinYeService.go

30 lines
639 B
Go
Raw Normal View History

2024-06-11 18:47:02 +08:00
package services
import (
"encoding/base64"
"encoding/json"
"fmt"
"qteam/app/http/entities/front"
)
func DecryptXyData(data string) (info front.XyDecryptData) {
// 解码
decodedBytes, err := base64.StdEncoding.DecodeString(data)
if err != nil {
fmt.Println("解码错误:", err)
return
}
fmt.Println("解码后的数据:", string(decodedBytes))
// 使用Hex.EncodeToString将字节切片转换为十六进制字符串
decrypt, err := SM2Decrypt(string(decodedBytes))
if err != nil {
return
}
err = json.Unmarshal([]byte(decrypt), &info)
if err != nil {
fmt.Println("解析JSON错误:", err)
return
}
return
}