We can using gzip and crypto with stream:

const fs = require('fs')
const zlib = require('zlib')
const file = process.argv[2];
const crypto = require('crypto');
const {Transform} = require('stream'); const progress = new Transform({
transform(chunk, encoding, callback) {
process.stdout.write('.')
callback(null, chunk)
}
}); //crypto + gzip
fs.createReadStream(file)
.pipe(zlib.createGzip())
.pipe(crypto.createCipher('aes192', 'a_secret'))
.pipe(progress)
//.on('data', () => process.stdout.write('.')) // loading / processing
.pipe(fs.createWriteStream(file + '.zz'))
.on('finish', () => console.log('DONE'));

Also unzip it:

// uncrypto + unzip
fs.createReadStream(file)
.pipe(crypto.createCipher('aes192', 'a_secret'))
.pipe(zlib.createGunzip())
.pipe(progress)
.pipe(fs.createWriteStream(file.slice(0, -3)))
.on('finish', () => console.log('DONE'))

最新文章

  1. MahApps.Metro使用
  2. [译]Thinking in React
  3. AE+C# 版本更新问题 命名空间“ESRI”中不存在类型或命名空间名称“Arcgis”(是缺少程序集引用吗?)
  4. Unity 游戏存档 PlayerPrefs类的用法
  5. Backbone☞View中的events...click事件失效
  6. zookeeper安装及部署
  7. Python变量/运算符/函数/模块/string
  8. placeholder的兼容性探索之路
  9. 使用JS制作一个鼠标可拖的DIV(三)——移动带图片DIV
  10. 【HDOJ】2388 Playground Hideout
  11. apache开源项目--PDFBox
  12. Central Europe Regional Contest 2012 Problem I: The Dragon and the Knights
  13. C++程序设计实践指导1.5求两个整数集合并集改写要求实现
  14. win32用GDI+加载png图片作为背景图
  15. 【C语言】判断三角形类型
  16. 修改Gradle 和Maven本地仓库的位置 方法
  17. SElinux用户管理操作
  18. SpringBoot之旅第五篇-数据访问
  19. thinkphp5.0引入类
  20. Gym 101775A - Chat Group - [简单数学题][2017 EC-Final Problem A]

热门文章

  1. gradle/maven/eclipse工程相互转化
  2. JBOSS集群和安装
  3. bzoj 4092 DP
  4. HDU 5150 Sum Sum Sum 素数
  5. php 获取所有常量
  6. 多线程面试题-sleep()和wait()区别
  7. java 程序消耗 cpu 100% 查找方法
  8. Oracle sql语句中(+)作用
  9. java基础学习总结——方法的重载(overload)
  10. android软件中加入广告实现方法