node.js能做什么_使用node.js对音视频文件加密的实例代码

更新时间:2021-08-14    来源:php入门    手机版     字体:

【www.bbyears.com--php入门】

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
};

本文来源:http://www.bbyears.com/jiaocheng/135839.html

猜你感兴趣