diff --git a/CHANGELOG.md b/CHANGELOG.md index 32be19d4..50a51959 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ +## v1.0.32 / 2021-12-25 + +- 优化aes方法 +- 增加base64方法 + ## v1.0.31 / 2021-12-24 - 增加美团联盟服务 - 优化http、request方法 + ## v1.0.30 / 2021-12-21 - 优化time方法、增加设置Unix时间戳方式 diff --git a/library.go b/library.go index a9cf4bbc..deadb4c8 100644 --- a/library.go +++ b/library.go @@ -1,5 +1,5 @@ package go_library func Version() string { - return "v1.0.31" + return "v1.0.32" } diff --git a/library_test.go b/library_test.go index ab83c1d0..d5da855c 100644 --- a/library_test.go +++ b/library_test.go @@ -1,12 +1,9 @@ package go_library import ( - "fmt" - "log" "testing" ) func TestVersion(t *testing.T) { - fmt.Println(Version()) - log.Println(Version()) + t.Log(Version()) } diff --git a/service/wechatpayapiv3/.gitignore b/service/wechatpayapiv3/.gitignore deleted file mode 100644 index 7a2230f3..00000000 --- a/service/wechatpayapiv3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -apiclient_cert.pem -apiclient_key.pem -app_test.go \ No newline at end of file diff --git a/service/wechatpayapiv3/app.go b/service/wechatpayapiv3/app.go index 3219fd10..991995f2 100644 --- a/service/wechatpayapiv3/app.go +++ b/service/wechatpayapiv3/app.go @@ -49,7 +49,7 @@ func (app *App) request(url string, params map[string]interface{}, method string return nil, result, err } req.Header.Add("Authorization", "WECHATPAY2-SHA256-RSA2048 "+authorization) - req.Header.Add("User-Agent", request.GetUserAgent()) + req.Header.Add("User-Agent", request.GetRandomUserAgent()) req.Header.Add("Content-Type", "application/json") req.Header.Add("Accept", "application/json") req.Header.Add("Accept-Language", "zh-CN") diff --git a/utils/aes/aes.go b/utils/goaes/goaes.go similarity index 99% rename from utils/aes/aes.go rename to utils/goaes/goaes.go index 492c4e1e..3692ec2e 100644 --- a/utils/aes/aes.go +++ b/utils/goaes/goaes.go @@ -1,4 +1,4 @@ -package aes +package goaes import ( "bytes" diff --git a/utils/gobase64/gobase64.go b/utils/gobase64/gobase64.go new file mode 100644 index 00000000..961e93d4 --- /dev/null +++ b/utils/gobase64/gobase64.go @@ -0,0 +1,17 @@ +package gobase64 + +import "encoding/base64" + +// Encode base64编码 +func Encode(input string) string { + return base64.StdEncoding.EncodeToString([]byte(input)) +} + +// Decode base64解码 +func Decode(input string) string { + decodeString, err := base64.StdEncoding.DecodeString(input) + if err != nil { + return "" + } + return string(decodeString) +} diff --git a/utils/gobase64/gobase64_test.go b/utils/gobase64/gobase64_test.go new file mode 100644 index 00000000..061d94dc --- /dev/null +++ b/utils/gobase64/gobase64_test.go @@ -0,0 +1,13 @@ +package gobase64 + +import ( + "testing" +) + +func TestEncode(t *testing.T) { + t.Log(Encode("广东茂名")) +} + +func TestDecode(t *testing.T) { + t.Log(Decode(Encode("广东茂名"))) +}