Parcourir la source

feat: change encrypt func name

Your Name il y a 3 ans
Parent
révision
23a17dfa8a
2 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 2
    2
      event.go
  2. 4
    4
      utils/encrypt/aes_encrypt.go

+ 2
- 2
event.go Voir le fichier

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

utils/encrypt/msg_encrypt.go → utils/encrypt/aes_encrypt.go Voir le fichier

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