diff --git a/gtoken/gtoken_test.go b/gtoken/gtoken_test.go index c7a55f2..d9d1b4f 100644 --- a/gtoken/gtoken_test.go +++ b/gtoken/gtoken_test.go @@ -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") + } + } + +}