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

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]

This is the code I have in the Code node:

const crypto = require('crypto');

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

var decipher = crypto.createDecipheriv(
var decrypted =
  decipher.update(encryptedNpi, 'hex', 'utf8') +'utf8');


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.