🗑 Remove uneeded code

This commit is contained in:
C-3PO 2018-07-08 22:24:06 +02:00
parent 4d5e0d403a
commit e355f6979a
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 0 additions and 31 deletions

View file

@ -1,31 +1,10 @@
import updateKeys from './lib/updateKeys'; import updateKeys from './lib/updateKeys';
/*export default function decryptChunk(encryptedChunk: Buffer, [key0, key1, key2]: [number, number, number]): {decryptedChunk: Buffer, keys: [number, number, number]} {
const decryptedChunk = Buffer.alloc(encryptedChunk.length);
const dvOut = new DataView(decryptedChunk.buffer);
for (let i = 0; i < encryptedChunk.length; i += 1) {
//read and decrypt byte
let curChar = encryptedChunk.readUInt8(i);
const keyPart = (key2 | 2) & 0xFFFF;
const decryptedByte = (keyPart * (keyPart ^ 1)) >>> 8;
curChar ^= decryptedByte & 0xFF;
dvOut.setUint8(i, curChar);
//update keys
[key0, key1, key2] = updateKeys([key0, key1, key2], curChar);
}
return { decryptedChunk, keys: [key0, key1, key2] };
}*/
export default function getDecryptor(decryptionKeys: [number, number, number]) { export default function getDecryptor(decryptionKeys: [number, number, number]) {
let [key0, key1, key2] = decryptionKeys; let [key0, key1, key2] = decryptionKeys;
let position = 0;
return (encryptedChunk: Buffer) => { return (encryptedChunk: Buffer) => {
const decryptedChunk = Buffer.alloc(encryptedChunk.length); const decryptedChunk = Buffer.alloc(encryptedChunk.length);
//const decryptedChunk = Buffer.alloc(encryptedChunk.length - Math.max(12 - position, 0));
for (let i = 0; i < encryptedChunk.length; i += 1) { for (let i = 0; i < encryptedChunk.length; i += 1) {
//read byte //read byte
@ -40,18 +19,9 @@ export default function getDecryptor(decryptionKeys: [number, number, number]) {
[key0, key1, key2] = updateKeys([key0, key1, key2], curChar); [key0, key1, key2] = updateKeys([key0, key1, key2], curChar);
//write byte //write byte
/*if (position + i < 12) {
//do nothing
} else if (position + i >= 12 && position < 12) {
decryptedChunk.writeUInt8(curChar, position + i - 12);
} else {
decryptedChunk.writeUInt8(curChar, i);
}*/
decryptedChunk.writeUInt8(curChar, i); decryptedChunk.writeUInt8(curChar, i);
} }
position += encryptedChunk.length;
return decryptedChunk; return decryptedChunk;
}; };
} }

View file

@ -32,7 +32,6 @@ export default async function getPatch(product: Product, from: number, to: numbe
//Then we need to wait for disks to finish download before we can extract individual files //Then we need to wait for disks to finish download before we can extract individual files
//TODO: we can optimize this to already extract some files as soon as their relevant parts are downloaded //TODO: we can optimize this to already extract some files as soon as their relevant parts are downloaded
const diskFilenames = await Promise.all(diskFiles); const diskFilenames = await Promise.all(diskFiles);
//const dvArray = bufferArray.map((buffer) => new DataView(buffer));
//TODO: Verify that downloaded files match the hash in `solidpkg.pieces` //TODO: Verify that downloaded files match the hash in `solidpkg.pieces`