Lua
Lua
Get the JWS Payload as a String
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetPayload, which returns the payload of a loaded JWS as text, decoded using the given charset.
Background. In practice, validate the signature before trusting the payload. Getting the payload retrieves the signed content.
Chilkat Lua Downloads
local chilkat = require("chilkat")
local jws = chilkat.Jws.new()
-- Load the JWS compact serialization.
local jwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
local success = jws:load_jws(jwsCompact)
if not success then
print(jws.last_error_text)
return
end
-- Return the JWS payload as text, decoded using the given charset.
local payload = jws:get_payload("utf-8")
if not jws.last_method_success then
print(jws.last_error_text)
return
end
print(payload)