dotenv, parsing fix email, moved dump tracnsport to new file gz, removed unwanted var jwt, added in HS256 sign/parse

ptr, ref and deref funcs response, use fmt.Fprint(f) validate, few new funcs
This commit is contained in:
2025-10-03 00:12:00 +05:30
parent 74e56f55d6
commit 6f9fb2d8ec
14 changed files with 262 additions and 65 deletions

View File

@@ -60,3 +60,28 @@ MC4CAQAwBQYDK2VwBCIEIMMkYUKJ9P0gp+Rm9mR4i0KUBT9nFUzxzxjH7sC0xq/F
fmt.Printf("%v", claims)
}
func TestHS256(t *testing.T) {
secret := []byte("c4c5fcb25e289e7a23763b013f04fd11b6b0247729216bb98d07f58332360aec")
claims := map[string]any{
"id": 1,
"email": "aa@aa.com",
}
issuer := "pat"
// Sign
jwt, err := SignHS256(secret, claims, issuer, time.Second)
if err != nil {
t.Error(err)
return
}
t.Log("jwt", jwt)
// Parse
_, err = ParseHS256(secret, jwt, issuer)
if err != nil {
t.Error(err)
return
}
}