| 12345678910111213141516171819202122232425262728293031 |
- package token
- import (
- "fmt"
- "testing"
- cherryCrypto "github.com/cherry-game/cherry/extend/crypto"
- )
- func TestAll(t *testing.T) {
- openId := "open_id_001"
- appKey := "app_key_abc"
- token := New(1, openId, appKey)
- fmt.Println(token)
- base64 := token.ToBase64()
- fmt.Println(base64)
- tokenString, _ := cherryCrypto.Base64Decode(base64)
- fmt.Println(tokenString)
- validateResult, ok := Validate(token, appKey)
- fmt.Println(validateResult, ok)
- }
- func TestTokenBase64(t *testing.T) {
- base64 := "eyJwbGF0Zm9ybV9pZCI6MjEyMjAwMywib3Blbl9pZCI6IjcxNjA5OTE5NjMwOTk5NTUyIiwidHQiOjE2MjY1MTk1MzAsImhhc2giOiIwMmIyYjY4ZDUxODY4MzliZDA2NGEzNDViN2UxNDFlYSJ9"
- tokenString, _ := cherryCrypto.Base64Decode(base64)
- fmt.Println(tokenString)
- }
|