Encrypt data on webhook and unencrypt

Hey I want to encrypt some data in a webhook which returns data so i can unencrypt on the other side. Any tips or suggestions? the data is not confidential but thought it would be also good to add some more protection.

Good morning,

We have a crypto node for encrypting and stuff.
Not sure why exactly you would want to do it though as HTTPS traffic is secured anyways. (assuming you have HTTPS set up)

Maybe give a bit more details and we can help you :slight_smile:

1 Like

Yep got what i needed using a code module with this javascript to encrypt a field from my database:

const crypto = require('crypto');

function encrypt(data, password, enc = 'base64') {
  const cipher = crypto.createCipheriv('aes-256-ecb', password, null); 
  const encrypted = cipher.update(data, 'utf8', 'base64') + cipher.final('base64');
  return { encrypted };
}

const plaintext =  $input.item["json"].memberID;
const password = '12345678901234567890123456789012';
return encrypt(plaintext, password);

If someone decides to use this dont forget to set NODE_FUNCTION_ALLOW_BUILTIN=crypto

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.