-
Hi, am new to paseto and I have been using jwt for a while, am switching to paseto for the reason that the claims are encrypted ( if i got it right ), am stuck in finding a way to use V4Symmetric encryption with my own secret also How can I verify it and extract the claims? |
Beta Was this translation helpful? Give feedback.
Answered by
oSethoum
Apr 6, 2023
Replies: 1 comment 3 replies
-
found it, it's really easy and straight forward package main
import (
"fmt"
"time"
"aidanwoods.dev/go-paseto"
)
func main() {
// producing token
token := paseto.NewToken()
token.SetExpiration(time.Now().Add(time.Hour * 12))
token.SetString("access", "products:view-many")
key := paseto.NewV4SymmetricKey()
t := token.V4Encrypt(key, []byte("secret"))
// validating token
vtoken, err := paseto.NewParser().ParseV4Local(key, t, []byte("secret"))
if err != nil {
panic(err)
} else {
println(vtoken.GetString("access"))
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
oSethoum
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
found it, it's really easy and straight forward
UPDATE: not an answer