如何使用node.js对音视频文件加密

这篇文章主要为大家展示了“如何使用node.js对音视频文件加密”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何使用node.js对音视频文件加密”这篇文章吧。

具体代码如下所示:

 fs.readFile('./downsuccess/'+name+'', {flag: 'r+', encoding: ''}, function (err, data) {
          console.log('读取中')
          if(err) {
            return;
          }
          let b = new Buffer(data);
          let c = b.toString('hex');
          let cipherBuffer = _this.cipher(data);
          fs.writeFile('./downsuccess/'+name+'',cipherBuffer,[],function(){
            console.log(`${name}加密完成`);
            _this.downAll(_this.downList,_this.downCall)
          })
        });
export function cipher (buf) {
  var encrypted = "";
  var cip = crypto.createCipher('rc4', '密匙');
  encrypted += cip.update(buf, 'hex', 'hex');
  encrypted += cip.final('hex');
  return encrypted
};

以上是“如何使用node.js对音视频文件加密”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!