Help whit node.js

Please, can anyone said me what i make wrong,thanks.

BLOCK:Script
INTERPRETER:NodeJS
INPUT message,pass
BEGIN SCRIPT
var crypto = require('crypto');

var encrypt = function(pass, message) {
  var salt = crypto.lib.WordArray.random(saltSize / 8);

  var key = crypto.PBKDF2(pass, salt, {keySize: keySize / 32, iterations: iterations});
  var iv = crypto.lib.WordArray.random(ivSize / 8);

  var encrypted = crypto.AES.encrypt(message, key, {
    iv: iv,
    padding: crypto.pad.Pkcs7,
    mode: crypto.mode.CBC
  });

  var encryptedHex = base64ToHex(encrypted.toString());

  let base64result = crypto.enc.Base64.parse(salt + iv + encryptedHex);
  
  var hash = base64result.toString(crypto.enc.Base64);

  return hash;
} 
END SCRIPT
OUTPUT String @hash
ENDBLOCK

Try This

var crypto = require(‘crypto’);

var encrypt = function(pass, message) {
var salt = crypto.randomBytes(saltSize / 8);

var key = crypto.pbkdf2Sync(pass, salt, iterations, keySize / 8, ‘sha512’);
var iv = crypto.randomBytes(ivSize / 8);

var cipher = crypto.createCipheriv(‘aes-256-cbc’, key, iv);
var encrypted = Buffer.concat([cipher.update(message, ‘utf8’), cipher.final()]);

var encryptedHex = encrypted.toString(‘hex’);

let base64result = Buffer.concat([salt, iv, Buffer.from(encryptedHex, ‘hex’)]);

var hash = base64result.toString(‘base64’);

return hash;
}

thanks but got the same error.

[Executing block Script] InvocationException: hash is not defined
ReferenceError: hash is not defined

try with chatgpt man ask for what do u want and he will make it i use it for my scripts