🗑 Remove uneeded code
This commit is contained in:
parent
4d5e0d403a
commit
e355f6979a
2 changed files with 0 additions and 31 deletions
|
@ -1,31 +1,10 @@
|
|||
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]) {
|
||||
let [key0, key1, key2] = decryptionKeys;
|
||||
let position = 0;
|
||||
|
||||
return (encryptedChunk: Buffer) => {
|
||||
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) {
|
||||
//read byte
|
||||
|
@ -40,18 +19,9 @@ export default function getDecryptor(decryptionKeys: [number, number, number]) {
|
|||
[key0, key1, key2] = updateKeys([key0, key1, key2], curChar);
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
position += encryptedChunk.length;
|
||||
|
||||
return decryptedChunk;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
//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 dvArray = bufferArray.map((buffer) => new DataView(buffer));
|
||||
|
||||
//TODO: Verify that downloaded files match the hash in `solidpkg.pieces`
|
||||
|
||||
|
|
Loading…
Reference in a new issue