使用node.js对音视频文件加密的实例代码
时间:2020-11-18 00:36:16|栏目:NodeJS|点击: 次
废话不多说了,直接给大家贴代码了,具体代码如下所示:
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 };
总结
栏 目:NodeJS
本文地址:http://www.codeinn.net/misctech/23747.html