Sample code for 30+ languages & platforms
React Native

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 React Native Downloads

React Native
import { JsonObject, Jwe } from '@chilkat/react-native'

function chilkatExample() {
  const jwe = new Jwe();

  // Load the JWE.
  const jweCompact = 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
  try {
    jwe.loadJwe(jweCompact);
  } catch {
    console.log(jwe.lastErrorText);
    return;
  }

  // Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
  // decoded or merged JOSE header.
  const json = new JsonObject();
  try {
    jwe.getHeader(json);
  } catch {
    console.log(jwe.lastErrorText);
    return;
  }

  json.emitCompact = false;
  console.log(json.emit());
}