我试图建立一个桌面应用程序与nodejs和电子播放加密(加密内置模块),嵌入式mp4视频文件。
下面是我的代码,它将解密的数据写入文件并通过它播放数据。有人能帮助我,使我的视频播放器通过内存播放数据,而不将数据写入文件吗?
var key ="12345678asdfghjk"
var keyBuf = new Buffer(key);
var inputStream = fs.createReadStream(file+"c");
var outputStream = fs.createWriteStream(file+"d");
var cipher = crypto.createDecipher("aes-128-cbc", keyBuf);
inputStream.on('data', function(data) {
var buf = new Buffer(cipher.update(data), 'binary');
outputStream.write(buf);
});
inputStream.on('end', function() {
try {
var buf = new Buffer(cipher.final('binary'), 'binary');
outputStream.write(buf);
outputStream.end();
outputStream.on('close', function() {
const introVideo=document.getElementById("introVideo");
introVideo.src = "data:video/mp4;base64,"+fs.readFileSync(file+"d", "base64")
introVideo.play()
});
} catch(e) {
console.log(e)
}
});
1条答案
按热度按时间fae0ux8s1#
我很抱歉延迟答复!@埃里克卡迈克尔如果你需要任何进一步的信息让我知道!