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

2022-01-14,,,,

本文通过实例代码给大家介绍了使用node.js对音视频文件加密的方法,非常不错,具有参考借鉴价值,需要的的朋友参考下吧

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

 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对音视频文件加密的实例代码的详细内容,更多请关注本站其它相关文章!

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

下载本文的Word格式文档,以方便收藏与打印。