From 337acaa35894ca64ffa0a4c8a6a38dc781e9354a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B0=E4=BA=AE?= Date: Sat, 16 Nov 2019 07:59:18 +0800 Subject: [PATCH] update go-util --- app/controller/test/test.go | 8 ++++---- app/route/middleware/sign/aes/aes.go | 4 ++-- app/route/middleware/sign/rsa/rsa.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/xinliangnote/go-util/aes/aes.go | 4 ++-- vendor/github.com/xinliangnote/go-util/rsa/rsa.go | 4 ++-- vendor/modules.txt | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controller/test/test.go b/app/controller/test/test.go index a1c219cb..a85648d1 100644 --- a/app/controller/test/test.go +++ b/app/controller/test/test.go @@ -33,10 +33,10 @@ func AesTest(c *gin.Context) { count := 1000000 for i := 0; i < count; i++ { // 生成签名 - sn, _ := aes.AesEncrypt(encryptStr, []byte(appSecret), appSecret) + sn, _ := aes.Encrypt(encryptStr, []byte(appSecret), appSecret) // 验证签名 - aes.AesDecrypt(sn, []byte(appSecret), appSecret) + aes.Decrypt(sn, []byte(appSecret), appSecret) } utilGin := response.Gin{Ctx: c} utilGin.Response(1, fmt.Sprintf("%v次 - %v", count, time.Since(startTime)), nil) @@ -48,10 +48,10 @@ func RsaTest(c *gin.Context) { count := 500 for i := 0; i < count; i++ { // 生成签名 - sn, _ := rsa.RsaPublicEncrypt(encryptStr, "rsa/public.pem") + sn, _ := rsa.PublicEncrypt(encryptStr, "rsa/public.pem") // 验证签名 - rsa.RsaPrivateDecrypt(sn, "rsa/private.pem") + rsa.PrivateDecrypt(sn, "rsa/private.pem") } utilGin := response.Gin{Ctx: c} utilGin.Response(1, fmt.Sprintf("%v次 - %v", count, time.Since(startTime)), nil) diff --git a/app/route/middleware/sign/aes/aes.go b/app/route/middleware/sign/aes/aes.go index 83074276..781bbb9a 100644 --- a/app/route/middleware/sign/aes/aes.go +++ b/app/route/middleware/sign/aes/aes.go @@ -87,7 +87,7 @@ func verifySign(c *gin.Context) (map[string]string, error) { return nil, errors.New("sn Error") } - decryptStr, decryptErr := aes.AesDecrypt(sn, []byte(AppSecret), AppSecret) + decryptStr, decryptErr := aes.Decrypt(sn, []byte(AppSecret), AppSecret) if decryptErr != nil { return nil, errors.New(decryptErr.Error()) } @@ -99,7 +99,7 @@ func verifySign(c *gin.Context) (map[string]string, error) { // 创建签名 func createSign(params url.Values) (string, error) { - return aes.AesEncrypt(createEncryptStr(params), []byte(AppSecret), AppSecret) + return aes.Encrypt(createEncryptStr(params), []byte(AppSecret), AppSecret) } func createEncryptStr(params url.Values) string { diff --git a/app/route/middleware/sign/rsa/rsa.go b/app/route/middleware/sign/rsa/rsa.go index c1a14217..1d7a8145 100644 --- a/app/route/middleware/sign/rsa/rsa.go +++ b/app/route/middleware/sign/rsa/rsa.go @@ -87,7 +87,7 @@ func verifySign(c *gin.Context) (map[string]string, error) { return nil, errors.New("sn Error") } - decryptStr, decryptErr := rsa.RsaPrivateDecrypt(sn, config.AppRsaPrivateFile) + decryptStr, decryptErr := rsa.PrivateDecrypt(sn, config.AppRsaPrivateFile) if decryptErr != nil { return nil, errors.New(decryptErr.Error()) } @@ -99,7 +99,7 @@ func verifySign(c *gin.Context) (map[string]string, error) { // 创建签名 func createSign(params url.Values) (string, error) { - return rsa.RsaPublicEncrypt(createEncryptStr(params), AppSecret) + return rsa.PublicEncrypt(createEncryptStr(params), AppSecret) } func createEncryptStr(params url.Values) string { diff --git a/go.mod b/go.mod index fc58be7e..9b4eeb15 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/uber-go/atomic v1.4.0 // indirect github.com/uber/jaeger-client-go v2.18.1+incompatible github.com/uber/jaeger-lib v2.1.1+incompatible // indirect - github.com/xinliangnote/go-util v0.0.0-20191109055458-c8d858c8d8b9 + github.com/xinliangnote/go-util v0.0.0-20191115235314-e7d1576d41db golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 google.golang.org/grpc v1.23.1 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect diff --git a/go.sum b/go.sum index e1001393..aa6ad682 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,8 @@ github.com/uber/jaeger-lib v2.1.1+incompatible h1:VY/6p2WopO09BPnw787RbaCIlfKbCR github.com/uber/jaeger-lib v2.1.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/xinliangnote/go-util v0.0.0-20191109055458-c8d858c8d8b9 h1:MoyZSQWPGWmLE8R5nIEUlxoxwaDYlz34Zh2K5QLgoKw= -github.com/xinliangnote/go-util v0.0.0-20191109055458-c8d858c8d8b9/go.mod h1:3ZornrplU9tYj9ar9jchik1XPQ10ZbSXkbgxXR5PVaU= +github.com/xinliangnote/go-util v0.0.0-20191115235314-e7d1576d41db h1:yReVDmqk6oBUOcSRUofahYHJlIwr7wrJ8yx1Ymkz84E= +github.com/xinliangnote/go-util v0.0.0-20191115235314-e7d1576d41db/go.mod h1:3ZornrplU9tYj9ar9jchik1XPQ10ZbSXkbgxXR5PVaU= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= diff --git a/vendor/github.com/xinliangnote/go-util/aes/aes.go b/vendor/github.com/xinliangnote/go-util/aes/aes.go index e9a35c77..5967aa8e 100644 --- a/vendor/github.com/xinliangnote/go-util/aes/aes.go +++ b/vendor/github.com/xinliangnote/go-util/aes/aes.go @@ -8,7 +8,7 @@ import ( ) // 加密 aes_128_cbc -func AesEncrypt (encryptStr string, key []byte, iv string) (string, error) { +func Encrypt (encryptStr string, key []byte, iv string) (string, error) { encryptBytes := []byte(encryptStr) block, err := aes.NewCipher(key) if err != nil { @@ -25,7 +25,7 @@ func AesEncrypt (encryptStr string, key []byte, iv string) (string, error) { } // 解密 -func AesDecrypt (decryptStr string, key []byte, iv string) (string, error) { +func Decrypt (decryptStr string, key []byte, iv string) (string, error) { decryptBytes, err := base64.URLEncoding.DecodeString(decryptStr) if err != nil { return "", err diff --git a/vendor/github.com/xinliangnote/go-util/rsa/rsa.go b/vendor/github.com/xinliangnote/go-util/rsa/rsa.go index a9948071..764f620a 100644 --- a/vendor/github.com/xinliangnote/go-util/rsa/rsa.go +++ b/vendor/github.com/xinliangnote/go-util/rsa/rsa.go @@ -10,7 +10,7 @@ import ( ) // 公钥加密 -func RsaPublicEncrypt(encryptStr string, path string) (string, error) { +func PublicEncrypt(encryptStr string, path string) (string, error) { // 打开文件 file, err := os.Open(path) if err != nil { @@ -46,7 +46,7 @@ func RsaPublicEncrypt(encryptStr string, path string) (string, error) { } // 私钥解密 -func RsaPrivateDecrypt(decryptStr string, path string) (string, error) { +func PrivateDecrypt(decryptStr string, path string) (string, error) { // 打开文件 file, err := os.Open(path) if err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 622858b5..dcaef5b7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,7 +60,7 @@ github.com/uber/jaeger-client-go/thrift-gen/baggage github.com/uber/jaeger-lib/metrics # github.com/ugorji/go v1.1.4 github.com/ugorji/go/codec -# github.com/xinliangnote/go-util v0.0.0-20191109055458-c8d858c8d8b9 +# github.com/xinliangnote/go-util v0.0.0-20191115235314-e7d1576d41db github.com/xinliangnote/go-util/aes github.com/xinliangnote/go-util/md5 github.com/xinliangnote/go-util/rsa