JavaScript Plugin Documentation

     Below is an example of how to encrypt ‘Report Ghosting’ data using JavaScript with the Node.js `crypto` module.

     const crypto = require(‘crypto’);

     // Function to encrypt data

     function encryptData(data, pluginKey) {

     // Ensure the pluginKey is in the correct format (e.g., hex or base64)

     const key = Buffer.from(pluginKey, ‘hex’); // Adjust according to your key format

     // Convert data to a string

     const dataString = JSON.stringify(data);

      // Generate a random IV

     const iv = crypto.randomBytes(16);

     // Create an AES-CBC cipher using the pluginKey and IV

     const cipher = crypto.createCipheriv(‘aes-256-cbc’, key, iv);

     // Encrypt the data

     let encrypted = cipher.update(dataString, ‘utf8’, ‘base64’);

    encrypted +=‘base64’);

     // Concatenate the IV and the encrypted data (IV needs to be shared for decryption)

     const ivBase64 = iv.toString(‘base64’);

     const encryptedDataWithIv = `${ivBase64}:${encrypted}`;

     return encryptedDataWithIv;


    // Example usage

   const pluginKey = ‘your_plugin_key_here’; // Replace with your actual pluginKey

   const reportGhostingData = {

    email: “[email protected]”,

    reason: “No response after several follow-ups”,

    date: “2024-03-26”


    const encryptedData = encryptData(reportGhostingData, pluginKey);


    console.log(‘Encrypted Data:’, encryptedData)