Python Plugin Documentation

   Python’s cryptography library offers comprehensive cryptographic functions. If it’s not already installed, you can install i  using pip: pip install cryptography.

 This example combines the randomly generated IV with the encrypted data, separated by a colon (`:`), and then encodes the entire payload in base64. This format ensures that the encrypted data and the IV are securely transmitted together.

from cryptography.hazmat.primitives import serialization, padding

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

from cryptography.hazmat.backends import default_backend

import os, base64, json

def encrypt_data(data, plugin_key_hex):

 plugin_key = bytes.fromhex(plugin_key_hex)  # Convert hex key to bytes

   iv = os.urandom(16)  # Generate a random 16-byte IV

   # Pad data to block size and convert to bytes

   padder = padding.PKCS7(algorithms.AES.block_size).padder()

   padded_data = padder.update(json.dumps(data).encode()) + padder.finalize()

   # Encrypt the data

   cipher = Cipher(algorithms.AES(plugin_key), modes.CBC(iv), backend=default_backend())

   encryptor = cipher.encryptor()

   encrypted_data = encryptor.update(padded_data) + encryptor.finalize()

   # Combine IV and encrypted data, then encode in base64

   encrypted_blob = base64.b64encode(iv + encrypted_data)

   return encrypted_blob.decode()

# Example usage

plugin_key = ‘your_plugin_key_here’  # Replace with your actual plugin key

report_ghosting_data = {

   “email”: “[email protected]”,

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

   “date”: “2024-03-26”


encrypted_data = encrypt_data(report_ghosting_data, plugin_key)


print(‘Encrypted Data:’, encrypted_data)