forked from xinliangnote/go-gin-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d3e3e8
commit f1ed621
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gin-gonic/gin" | ||
"go-gin-api/app/util" | ||
"time" | ||
) | ||
|
||
func Md5Test(c *gin.Context) { | ||
startTime := time.Now() | ||
appSecret := "IgkibX71IEf382PT" | ||
encryptStr := "param_1=xxx¶m_2=xxx&ak=xxx&ts=1111111111" | ||
count := 1000000 | ||
for i := 0; i < count; i++ { | ||
// 生成签名 | ||
util.MD5(appSecret + encryptStr + appSecret) | ||
|
||
// 验证签名 | ||
util.MD5(appSecret + encryptStr + appSecret) | ||
} | ||
utilGin := util.Gin{Ctx: c} | ||
utilGin.Response(1, fmt.Sprintf("%v次 - %v", count, time.Since(startTime)), nil) | ||
} | ||
|
||
func AesTest(c *gin.Context) { | ||
startTime := time.Now() | ||
appSecret := "IgkibX71IEf382PT" | ||
encryptStr := "param_1=xxx¶m_2=xxx&ak=xxx&ts=1111111111" | ||
count := 1000000 | ||
for i := 0; i < count; i++ { | ||
// 生成签名 | ||
sn, _ := util.AesEncrypt(encryptStr, []byte(appSecret), appSecret) | ||
|
||
// 验证签名 | ||
util.AesDecrypt(sn, []byte(appSecret), appSecret) | ||
} | ||
utilGin := util.Gin{Ctx: c} | ||
utilGin.Response(1, fmt.Sprintf("%v次 - %v", count, time.Since(startTime)), nil) | ||
} | ||
|
||
func RsaTest(c *gin.Context) { | ||
startTime := time.Now() | ||
encryptStr := "param_1=xxx¶m_2=xxx&ak=xxx&ts=1111111111" | ||
count := 500 | ||
for i := 0; i < count; i++ { | ||
// 生成签名 | ||
sn, _ := util.RsaPublicEncrypt(encryptStr, "rsa/public.pem") | ||
|
||
// 验证签名 | ||
util.RsaPrivateDecrypt(sn, "rsa/private.pem") | ||
} | ||
utilGin := util.Gin{Ctx: c} | ||
utilGin.Response(1, fmt.Sprintf("%v次 - %v", count, time.Since(startTime)), nil) | ||
} |