import{createCipheriv,randomBytes,scrypt}from'crypto';import{promisify}from'util';constiv=randomBytes(16);constpassword='Password used to generate key';// The key length is dependent on the algorithm.// In this case for aes256, it is 32 bytes.constkey=(awaitpromisify(scrypt)(password,'salt',32))asBuffer;constcipher=createCipheriv('aes-256-ctr',key,iv);consttextToEncrypt='Nest';constencryptedText=Buffer.concat([cipher.update(textToEncrypt),cipher.final(),]);