您的位置:首页 > Web前端 > Node.js

使用node.js对音视频文件加密

2017-08-29 18:00 489 查看
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
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: