diff --git a/main.go b/main.go
index edfebc2..ae8785b 100644
--- a/main.go
+++ b/main.go
@@ -25,11 +25,12 @@ func main() {
`
- m := Decode(txt)
t := Encode(msg)
+ m := Decode(t)
+
fmt.Println(t)
fmt.Println(m)
- fmt.Println(t == txt)
+
fmt.Println(m == msg)
return
diff --git a/messageEncrypt.go b/messageEncrypt.go
index 0a6b932..b792969 100644
--- a/messageEncrypt.go
+++ b/messageEncrypt.go
@@ -8,12 +8,10 @@ import (
"fmt"
)
-var random16 []byte
-
//Encode convert a xml sequence into encrypted message
func Encode(s string) string {
- d := aesEncryptMsg(random16, []byte(s), APIConfig.Appid, getAesEncryptKey())
+ d := aesEncryptMsg(random16Byte(), []byte(s), APIConfig.Appid, getAesEncryptKey())
r := base64.StdEncoding.EncodeToString(d)
fmt.Println(r)
return r
@@ -24,11 +22,8 @@ func Decode(s string) string {
r, _ := base64.StdEncoding.DecodeString(s)
- r16, raw, err := aesDecryptMsg([]byte(r), APIConfig.Appid, getAesEncryptKey())
- random16 = make([]byte, 16)
- copy(random16, r16)
+ _, raw, err := aesDecryptMsg([]byte(r), APIConfig.Appid, getAesEncryptKey())
if err == nil {
- fmt.Println(string(raw))
return string(raw)
}
return ""