header
{
'typ': 'JWT',
'alg': 'HS256'
}
playload
{
"sub": "1234567890",
"name": "John Doe",
"admin": true
}
java代码
String str = Jwts.builder()
.setHeaderParam("typ", "JWT")
.setHeaderParam("alg", "HS256")
.claim("sub","1234567890")
.claim("name", "John Doe")
.claim("admin", true)
.signWith(SignatureAlgorithm.HS256, key.getBytes("UTF-8"))
.compact();