https://github.com/deatil/go-jwt-gm
A JWT GM(China GuoMi) driver library for go-jwt.
https://github.com/deatil/go-jwt-gm
gm jws jwt jwt-gm sm2 sm3
Last synced: about 1 month ago
JSON representation
A JWT GM(China GuoMi) driver library for go-jwt.
- Host: GitHub
- URL: https://github.com/deatil/go-jwt-gm
- Owner: deatil
- License: apache-2.0
- Created: 2025-06-27T16:21:40.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-06-27T16:59:23.000Z (3 months ago)
- Last Synced: 2025-06-27T17:32:53.288Z (3 months ago)
- Topics: gm, jws, jwt, jwt-gm, sm2, sm3
- Language: Go
- Homepage: https://pkg.go.dev/github.com/deatil/go-jwt-gm
- Size: 11.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## go-jwt-gm
### Desc
* A JWT GM(China GuoMi) driver library for go.
### Download
~~~go
go get -u github.com/deatil/go-jwt-gm
~~~### Get Starting
~~~go
package mainimport (
"fmt""github.com/deatil/go-jwt-gm/jwt"
)func main() {
claims := map[string]string{
"aud": "example.com",
"sub": "foo",
}
key := []byte("test-key")s := jwt.SigningMethodHSM3.New()
tokenString, err := s.Sign(claims, key)
if err != nil {
fmt.Printf("Sign: %s \n", err.Error())
return
}fmt.Printf("Signed: %s \n", tokenString)
p := jwt.SigningMethodHSM3.New()
parsed, err := p.Parse(tokenString, key)
if err != nil {
fmt.Printf("Parse: %s \n", err.Error())
return
}claims2, err := parsed.GetClaims()
if err != nil {
fmt.Printf("GetClaims: %s \n", err.Error())
return
}aud := claims2["aud"].(string)
fmt.Printf("Parseed aud: %s \n", aud)
}
~~~### Signing Methods
The JWT GM driver library have signing methods:
- `HSM3`: jwt.SigningMethodHSM3
- `GmSM2`: jwt.SigningMethodGmSM2
- `ES256K`: jwt.SigningMethodES256K### LICENSE
* The library LICENSE is `Apache2`, using the library need keep the LICENSE.
### Copyright
* Copyright deatil(https://github.com/deatil).