github.com/TeaOSLab/EdgeNode@v1.3.8/internal/encrypt/magic_key.go (about) 1 package encrypt 2 3 import ( 4 "github.com/iwind/TeaGo/logs" 5 ) 6 7 const ( 8 MagicKey = "f1c8eafb543f03023e97b7be864a4e9b" 9 ) 10 11 // 加密特殊信息 12 func MagicKeyEncode(data []byte) []byte { 13 method, err := NewMethodInstance("aes-256-cfb", MagicKey, MagicKey[:16]) 14 if err != nil { 15 logs.Println("[MagicKeyEncode]" + err.Error()) 16 return data 17 } 18 19 dst, err := method.Encrypt(data) 20 if err != nil { 21 logs.Println("[MagicKeyEncode]" + err.Error()) 22 return data 23 } 24 return dst 25 } 26 27 // 解密特殊信息 28 func MagicKeyDecode(data []byte) []byte { 29 method, err := NewMethodInstance("aes-256-cfb", MagicKey, MagicKey[:16]) 30 if err != nil { 31 logs.Println("[MagicKeyEncode]" + err.Error()) 32 return data 33 } 34 35 src, err := method.Decrypt(data) 36 if err != nil { 37 logs.Println("[MagicKeyEncode]" + err.Error()) 38 return data 39 } 40 return src 41 }