当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 使用node.js对音视频文件加密的实例代码

使用node.js对音视频文件加密的实例代码

2017年12月12日  | 移动技术网IT编程  | 我要评论

废话不多说了,直接给大家贴代码了,具体代码如下所示:

 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对音视频文件加密的实例代码,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网