Lua
Lua
Set the JWS Protected Header
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.SetProtectedHeader, which sets the integrity-protected header for a signer from a JsonObject. The header specifies the signature algorithm (alg).
Background. The protected header is covered by the signature, so it cannot be altered without invalidating the JWS. It is configured before creating the JWS.
Chilkat Lua Downloads
local chilkat = require("chilkat")
local jws = chilkat.Jws.new()
-- Build the JWS protected header. The "alg" member names the signature algorithm.
local header = chilkat.JsonObject.new()
header:update_string("alg", "HS256")
-- Set the protected header for signer index 0. The protected header is integrity-protected: it is
-- covered by the signature.
local success = jws:set_protected_header(0, header)
if not success then
print(jws.last_error_text)
return
end
print("Protected header set.")