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!