Skip to content

Commit

Permalink
add benchmark decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jul 8, 2019
1 parent ed181ed commit 441afd2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions gtoken/gtoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,31 @@ func TestEncryptDecryptToken(t *testing.T) {
}

}

func BenchmarkEncryptDecryptToken(b *testing.B) {
b.Log("encrypt and decrypt token test ")
gtoken := gtoken.GfToken{}
gtoken.Init()

userKey := "123123"
token := gtoken.EncryptToken(userKey)
if !token.Success() {
b.Error(token.Json())
}
b.Log(token.DataString())

for i := 0; i < b.N; i++ {
token2 := gtoken.DecryptToken(token.GetString("token"))
if !token2.Success() {
b.Error(token2.Json())
}
b.Log(token2.DataString())
if userKey != token2.GetString("userKey") {
b.Error("token decrypt userKey error")
}
if token.GetString("uuid") != token2.GetString("uuid") {
b.Error("token decrypt uuid error")
}
}

}

0 comments on commit 441afd2

Please sign in to comment.