🐛 Fix length calculation during decryption

This commit is contained in:
C-3PO 2018-06-24 02:15:46 +02:00
parent 589f7fe786
commit 52157f544c
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -1,7 +1,7 @@
import updateKeys from './updateKeys';
export default function decryptFile(dv: DataView, length: number, [key0, key1, key2]: [number, number, number]) {
const decryptedBuffer = new ArrayBuffer(dv.byteLength - 12);
const decryptedBuffer = new ArrayBuffer(length - 12);
const dvOut = new DataView(decryptedBuffer);
for (let i = 0; i < length; i += 1) {
@ -19,6 +19,5 @@ export default function decryptFile(dv: DataView, length: number, [key0, key1, k
[key0, key1, key2] = updateKeys([key0, key1, key2], curChar);
}
//If it was decrypted, we skip the first 12 bytes (random encryption header)
return dvOut;
}