How can AES encrypted files be partially decrypted?

  node.js, question

How can AES encrypted files be partially decrypted?
If the whole file is encrypted and decrypted, I know what to do. As shown below. But now the demand is to decrypt only part of the file. For example, a 1G file can only be decrypted for the last 1M. Can you tell me how to do it?
The encryption algorithm now usesAES-256-CTR

var crypto = require('crypto');
 var fs = require('fs-extra');
 var encrypt = crypto.createCipher('AES-256-CTR', 'segmentfault');
 var decrypt = crypto.createDecipher('AES-256-CTR', 'segmentfault');
 var encryptName = 'encrypt.txt';
 var decryptName = 'decrypt.txt';
 fs.createReadStream('decrypt.js').pipe(encrypt).pipe(fs.createWriteStream(encryptName)).on('finish', () => {
 fs.createReadStream(encryptName).pipe(decrypt).pipe(fs.createWriteStream(decryptName));
 });

The problem has been solved.
Use this modulehttps://npm.taobao.org/packag …

var crypto = require('crypto');
 var fs = require('fs-extra');
 var encryptName = 'encrypt.txt';
 var decryptName = 'decrypt.txt';
 var cryptoAesCtr = require("crypto-aes-ctr");
 var key = new Buffer("8fbf35890fc3e0d5bc615cb091f16e8d40cfe3d4223cd68b11e2e7204d890210", "hex");
 var iv = new Buffer("4395a3ded2f0040835d437cc9fa7a7dc", "hex");
 fs.createReadStream('decrypt.js').pipe(encrypt).pipe(fs.createWriteStream(encryptName)).on('finish', () => {
 //Suppose 3 AES blocks are skipped, each AES block is 16 bytes
 var aesBlockSize = 16;
 var counter = 3;
 fs.createReadStream(encryptName, {start: aesBlockSize * counter}).pipe(cryptoAesCtr.createStream(key, iv, counter)).pipe(fs.createWriteStream(decryptName));
 });