Sample code for 30+ languages & platforms
React Native

Example: Crypt2.GetSignedAttributes method

Demonstrates how to call the GetSignedAttributes method.

Chilkat React Native Downloads

React Native
import { BinData, Crypt2, JsonObject, StringBuilder } from '@chilkat/react-native'

function chilkatExample() {
  const crypt = new Crypt2();

  const bdPkcs7 = new BinData();
  try {
    bdPkcs7.loadFile('qa_data/cades/CAdES-T/Signature-C-T-1.p7m');
  } catch {
    console.log(bdPkcs7.lastErrorText);
    return;
  }

  const json = new JsonObject();
  json.emitCompact = false;

  const sbJson = new StringBuilder();
  let i = 0;
  let tryNext = true;
  while (tryNext) {
    if (crypt.getSignedAttributes(i, bdPkcs7, sbJson)) {
      json.loadSb(sbJson);
      console.log(`${i}: `);
      console.log(json.emit());
    } else {
      tryNext = false;
    }

    i++;
  }

  // Sample output:

  // 0: 
  // {
  //   "signedAttributes": [
  //     {
  //       "oid": "1.2.840.113549.1.9.3",
  //       "name": "Content Type"
  //     },
  //     {
  //       "oid": "1.2.840.113549.1.9.5",
  //       "name": "Signing Time"
  //     },
  //     {
  //       "oid": "1.2.840.113549.1.9.4",
  //       "name": "Message Digest"
  //     },
  //     {
  //       "oid": "1.2.840.113549.1.9.16.2.47",
  //       "name": "Signing Certificate V2"
  //     }
  //   ]
  // }
}