Decode AES with the code node, but getting an error "Cannot find module crypto"

Hey,
I’ve been trying to decrypt AES by using a script in the code node, but I keep getting the following error:

ERROR: Cannot find module 'crypto' [line 1]
VMError

This is the code I have in the Code node:

const crypto = require('crypto');

var encryptedNpi = '--encrypted-string-here--';

var decipher = crypto.createDecipheriv(
  'aes-192-ecb',
  '--decypher-key-here--',
  ''
);
var decrypted =
  decipher.update(encryptedNpi, 'hex', 'utf8') + decipher.final('utf8');

console.log(decrypted);

return {
  decrypted: decrypted,
};

Any help on how I can make it work?

Thanks beforehand.

I’m not exactly sure but afaik, n8n requires the output to be an Array of JS objects
So can you try doing this

return return [ { "decrypted" : decrypted } ]

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