Sample code for 30+ languages & platforms
Classic ASP

Set the JWE Protected Header

See more JSON Web Encryption (JWE) Examples

Demonstrates Jwe.SetProtectedHeader, which sets the integrity-protected JWE header from a JsonObject. The header specifies the key-management algorithm (alg) and content-encryption algorithm (enc).

Background. The protected header is integrity-protected and applies to all recipients. It is configured before encrypting.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set jwe = Server.CreateObject("Chilkat.Jwe")

'  Build the JWE protected header.  The "alg" member names the key-management algorithm and the "enc"
'  member names the content-encryption algorithm.
set header = Server.CreateObject("Chilkat.JsonObject")
success = header.UpdateString("alg","A256KW")
success = header.UpdateString("enc","A256GCM")

'  Set the protected header on the JWE.  The protected header is integrity-protected and applies to
'  all recipients.
success = jwe.SetProtectedHeader(header)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( jwe.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Protected header set.") & "</pre>"

%>
</body>
</html>