小编Gau*_*sak的帖子

在 NodeJs 中使用 AES GCM 加密的流媒体视频

我有一些从 S3 流式传输未加密视频的代码,现在我想让它适用于加密视频文件,为此我使用 AES GCM。

但是html5播放器无法播放。我尝试解密完整文件并且它有效(没有流媒体)。任何建议将不胜感激。该代码适用于 HapisJS。

      const file = 'test/movie.mp4.enc';
      const s3Bucket = new S3();
      const paramsWholeFile = { Bucket: 'mybucket-v1', Key: file};
      const headWholeFile = await s3Bucket.headObject(paramsWholeFile).promise();
      const fileSize = headWholeFile.ContentLength!;

      const range = req.headers.range;
      console.log(range);

      const parts = range.replace(/bytes=/, "").split("-")
      let start = parseInt(parts[0], 10);
      if (start > 0) {
        start -= (start % 16); // reading from the beginning of AES block
      }

      let end = parts[1]
        ? parseInt(parts[1], 10) - parseInt(parts[1], 10) % 16 # …
Run Code Online (Sandbox Code Playgroud)

javascript cryptography aes node.js hapi.js

6
推荐指数
0
解决办法
726
查看次数

标签 统计

aes ×1

cryptography ×1

hapi.js ×1

javascript ×1

node.js ×1