Skip to content

Commit

Permalink
update go-util
Browse files Browse the repository at this point in the history
  • Loading branch information
xinliangnote committed Nov 15, 2019
1 parent 2f47791 commit 337acaa
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/controller/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/route/middleware/sign/aes/aes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions app/route/middleware/sign/rsa/rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions vendor/github.com/xinliangnote/go-util/aes/aes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/xinliangnote/go-util/rsa/rsa.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 337acaa

Please sign in to comment.