Sample code for 30+ languages & platforms
Lua

Get the Entire Loaded JWE Structure

See more JSON Web Encryption (JWE) Examples

Demonstrates Jwe.GetHeader, which copies the entire currently loaded JWE structure into a JsonObject.

Background. This is the full JWE representation, not a decoded or merged JOSE header. It can contain the protected, unprotected, and per-recipient header material.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local jwe = chilkat.Jwe.new()

-- Load the JWE.
local jweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
local success = jwe:load_jwe(jweCompact)
if not success then
    print(jwe.last_error_text)
    return
end

-- Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
-- decoded or merged JOSE header.
local json = chilkat.JsonObject.new()
success = jwe:get_header(json)
if not success then
    print(jwe.last_error_text)
    return
end

json.emit_compact = false
print(json:emit())