Home  >  Article  >  Web Front-end  >  Node.js operates audio and video files to encrypt them

Node.js operates audio and video files to encrypt them

php中世界最好的语言
php中世界最好的语言Original
2018-04-18 15:19:501863browse

This time I will bring you node.jsOperation soundVideo file encryption, node.js operation audio and video file encryptionNotesWhat are they? The following is a practical case. Let’s take a look.

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

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Combining HTML tags with DOM nodes

What are the ways to introduce js into the page

The above is the detailed content of Node.js operates audio and video files to encrypt them. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn