package basic import ( "crypto/sha256" "encoding/base64" "fusenapi/utils/auth" "log" "testing" ) func TestRequestParse(t *testing.T) { a, us, err := auth.TParseJwtTokenHeader[auth.UserInfo]("saTGjruwq7SG4vnQVEo3vsZvbfhzx8zZ3zWA+8nWVdid5tssnYQNECiP+pYCK6YhZ+LRH8m7f7JXrgyqtpYQMOhVOcNWTYAClk0Jnft6+QIPegzY9+v4k7eVMiWf5c/x") log.Println(a, us, err) } func TestHash(t *testing.T) { a := "fs12345678" h := sha256.New() h.Write([]byte(a)) s := base64.RawURLEncoding.EncodeToString(h.Sum(nil)) key := auth.StringToHash(s) // log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 400000000, time.Now().UTC().Unix(), 39, 0)) authkey := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjIwOTMxOTIyMjYsImd1ZXN0X2lkIjowLCJpYXQiOjE2OTMxOTIyMjYsInVzZXJfaWQiOjM5fQ.DrvtD7gKB0gz1rAOAQHSnyBK3exTFqoLlacpZiadpB4" log.Println(authkey) log.Println(auth.TParseJwtTokenHeader[auth.UserInfo](authkey)) log.Println(auth.ParseJwtTokenUint64Secret(authkey, key)) }