我正在尝试在下载和使用FileReader API时对视频文件进行加密。下面是我的代码:
leadGenSubmit() {
let headers = new HttpHeaders();
let reader = new FileReader();
headers = headers.set("Accept", "video/mp4");
let url = "http://static.videogular.com/assets/videos/videogular.mp4";
let filename = url.substring(url.lastIndexOf('/')+1);
return this.http
.get(url, { headers: headers, responseType: "blob" })
.subscribe(
data => {
console.log(data);
var blob = new Blob([data], { type: "video/mp4" });
var myPassword = "myPassword";
var encrypted = CryptoJS.AES.encrypt(reader.result, myPassword);
console.log("Encrypted" + encrypted);
reader.readAsDataURL(blob);
saveAs(blob, filename);
},
err => {
console.log(err);
}
);
}
我调试了一下,发现它正在记录不同的加密密钥,但是我无法确定它是否已加密。