瀏覽代碼

feat: change encrypt func name

Your Name 3 年之前
父節點
當前提交
23a17dfa8a
共有 2 個文件被更改,包括 6 次插入6 次删除
  1. 2
    2
      event.go
  2. 4
    4
      utils/encrypt/aes_encrypt.go

+ 2
- 2
event.go 查看文件

48
 		return nil, e1
48
 		return nil, e1
49
 	}
49
 	}
50
 
50
 
51
-	bt2, e2 := encrypt.MsgDecode(bt1, aesKey)
51
+	bt2, e2 := encrypt.AESDecode(bt1, aesKey)
52
 	if e2 != nil {
52
 	if e2 != nil {
53
 		log.Error("解码加密数据失败: ", e2.Error())
53
 		log.Error("解码加密数据失败: ", e2.Error())
54
 		log.Error("待解密数据: ", string(bt1))
54
 		log.Error("待解密数据: ", string(bt1))
79
 	data = append(data, src...)
79
 	data = append(data, src...)
80
 	data = append(data, []byte(appID)...)
80
 	data = append(data, []byte(appID)...)
81
 
81
 
82
-	bt1, e1 := encrypt.MsgEncode(data, aesKey)
82
+	bt1, e1 := encrypt.AESEncode(data, aesKey)
83
 	if e1 != nil {
83
 	if e1 != nil {
84
 		log.Error("加密数据失败: ", e1.Error())
84
 		log.Error("加密数据失败: ", e1.Error())
85
 		log.Error("待加密数据: ", string(bt1))
85
 		log.Error("待加密数据: ", string(bt1))

utils/encrypt/msg_encrypt.go → utils/encrypt/aes_encrypt.go 查看文件

19
 	"errors"
19
 	"errors"
20
 )
20
 )
21
 
21
 
22
-// MsgEncode 使用 AES CBC 模式加密数据
22
+// AESEncode 使用 AES CBC 模式加密数据
23
 // data 为待加密数据
23
 // data 为待加密数据
24
-func MsgEncode(data, key []byte) ([]byte, error) {
24
+func AESEncode(data, key []byte) ([]byte, error) {
25
 	if nil == data || len(data) == 0 {
25
 	if nil == data || len(data) == 0 {
26
 		return nil, errors.New("待加密 消息 为空")
26
 		return nil, errors.New("待加密 消息 为空")
27
 	}
27
 	}
49
 	return dist, nil
49
 	return dist, nil
50
 }
50
 }
51
 
51
 
52
-// MsgDecode 是 MsgEncode 的反操作, 用来解密数据
52
+// AESDecode 是 AESEncode 的反操作, 用来解密数据
53
 // data 为待解密数据
53
 // data 为待解密数据
54
-func MsgDecode(data, key []byte) ([]byte, error) {
54
+func AESDecode(data, key []byte) ([]byte, error) {
55
 	if nil == data || len(data) == 0 {
55
 	if nil == data || len(data) == 0 {
56
 		return nil, errors.New("待解密 消息 为空")
56
 		return nil, errors.New("待解密 消息 为空")
57
 	}
57
 	}