|
|
|
@@ -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 "" |